Function declarations with lexical `this`?
Axel Rauschmayer
axel at rauschma.de
Mon Jun 24 23:37:39 PDT 2013
> What’s the best way to solve this and to eliminate the pitfall of dynamic `this` (at least for beginners)? Tell people to const-bind arrow functions?
>
> IMO, yes.
>
>
> We’d lose hoisting, though.
>
> yes. I don't think this will actually be a problem in practice.
That makes sense, thank you.
> I also wouldn’t want to lose the symmetry function declaration/generator declaration and method definition/generator method definition.
>
> I do sometimes wish there was a natural place to put a "*" on an arrow function, and sometimes I don't wish it. In any case, it's not gonna happen in ES6.
Given that generators use the `this` that the function would have (at least that’s how I read the spec – `this` is the global object for a non-strict generator function, `undefined` for a strict generator function, the receiver of the method invocation for a generator method), a generator arrow function would even be useful: a generator with lexical `this`.
--
Dr. Axel Rauschmayer
axel at rauschma.de
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130625/e22aa9ae/attachment.html>
More information about the es-discuss
mailing list