arrow function syntax simplified

Herby Vojčík herby at
Thu Mar 29 03:05:43 PDT 2012

Brendan Eich wrote:
> Kevin Smith wrote:
>> I hate the CoffeeScript deviation, though. It's just confusing for
>> anyone who ever learned that fat-arrow binds |this| and thin-arrow
>> doesn't.
>> True. On the other hand, "all arrows bind |this|" is also quite simple
>> and easy to remember.
> Yes, and I kept the part of the proposal that allows |this| as a leading
> arrow formal parameter, including with parameter default value. This
> suggests a slight variation on the strawman, per your suggestion:
> x -> { return this.x; } // lexical this for thin arrow
> x => this.x // as for fat arrow
> (this, x) -> { return this.x; } // dynamic this, five letter syn-tax
> (this, x) => this.x // ditto for the expression-body form

I like this very much. Clear, orthogonal, readable.
It would be nice if this could get through.

> /be


P.S.: Dynamic this no-arg function could also use one-arg shorthand?

this => this.x
this -> { return this.x; }

More information about the es-discuss mailing list