Clarification on function default param values

classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Clarification on function default param values

Claus Reinke
> 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).

Claus
 
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Clarification on function default param values

Brendan Eich-3
In reply to this post by Andrea Giammarchi-2
Thread-hijacking is poor form.

/be
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Clarification on function default param values

Andrea Giammarchi-2
oops, it wasn't intentional. I should have checked ... opened a new one.

br


On Tue, Oct 1, 2013 at 3:39 PM, Brendan Eich <[hidden email]> wrote:
Thread-hijacking is poor form.

/be


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Clarification on function default param values

Mark S. Miller
In reply to this post by Claus Reinke
On Tue, Oct 1, 2013 at 3:16 PM, Claus Reinke <[hidden email]> 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

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
12