Function declarations with lexical `this`?

Axel Rauschmayer axel at
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


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

More information about the es-discuss mailing list