Sugar for *.prototype and for calling methods as functions

Axel Rauschmayer axel at
Tue Feb 21 03:52:49 PST 2012

The established way of doing this is [].forEach, "".trim, {}.valueOf. I imagine that by now, there would be no performance penalty, any more, because most engines are aware of this (ab)use. But it is indeed not very intention-revealing. It might make sense to wait with this proposal until classes are finished, but they probably won’t introduce any changes at this level.

On Feb 21, 2012, at 12:16 , Mariusz Nowak wrote:

> Sorry if it already has been picked up (I searched and didn't found anything
> close that).
> In my last months of work with JavaScript what that I miss a lot in ES5
> syntax is:
> 1. Syntax shortcut for '.prototype'. Instead of writing
> String.prototype.trim I'd love to be able to write for example String#trim 
> (it's not proposal, just example how it may look).
> As most native ES methods are generic there are a lot of valid use cases for
> that e.g.:
>, fn);
> 2. Syntax sugar for calling method as a function. In following examples I
> just place '@' at end of method that I'd like to be run as function.
> Array#forEach@(listThatsNotArray, fn));
> or 
> trimmedListOfStrings =;
> Last example is same as following in ES5:
> trimmedListOfStrings =
> This two proposals will make methods easily accessible for some functional
> constructs, and I think might be revolutionary for those who favor such
> functional way of programming.
> Let me know what do you think about that.

Dr. Axel Rauschmayer
axel at


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list