Clarification regarding "top level" arrow functions and "this"/"arguments"
nbdd0121 at hotmail.com
Wed Jan 21 19:08:20 PST 2015
I think the spec is clear. The hasThisBinding of function environment record of arrow function will return false, thus always trace to the outer environment - in your case, could be global environment record or module environment record, which resolves the this binding to either global object or undefined.
> Date: Wed, 21 Jan 2015 10:13:39 -0800
> From: list at felix-kling.de
> To: es-discuss at mozilla.org
> Subject: Clarification regarding "top level" arrow functions and "this"/"arguments"
> > Any reference to `arguments`, `super`, or `this` within an
> > *ArrowFunction* are resolved to their bindings in the lexically
> > enclosing function.
> However, what if there is no enclosing function? Shouldn't this say
> "enclosing environment"?
> If yes, what would be the expected behavior of an arrow function that
> references `this` and `arguments`?
> I assume in case of `this`, it would just resolve to the *thisBinding*
> of the environment (if there is one). Since there is no `arguments`
> binding (by default) I assume accessing `arguments` would throw a
> reference error.
> Is my understanding correct?
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss