Clarification on function default param values

Mark Miller erights at gmail.com
Tue Oct 1 18:09:14 PDT 2013


On Tue, Oct 1, 2013 at 3:16 PM, Claus Reinke <claus.reinke at talk21.com>wrote:

> Generally variables are brought into scope by an explicitly appearing
>> defining occurrence. Two exceptions are the "function" brings into scope
>> both "this" and "arguments". These remain in scope until shadowed by a
>> nested "function" or by an explicit definition. Note that "this" can never
>> be explicitly defined, and "arguments" can only be explicitly defined in
>> non-strict code.
>>
>> As of ES6, a variety of other function-defining constructs, like
>> "function", implicitly bring into scope a new "this" and "argument".
>> Arrow-functions are not one of these. Within an arrow function, both
>> "this"
>> and "arguments" are lexically captured from the enclosing context.
>>
>
> Also "super" (implicitly bound in "function", available lexically scoped
> in arrow function body).
> Still following the rule: arrow functions have no implicit bindings and do
> not interfere with lexical scope (other than adding explicit bindings for
> their parameters).


Excellent point!


-- 
  Cheers,
  --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131001/3833befd/attachment-0001.html>


More information about the es-discuss mailing list