Clarification on function default param values

Brandon Benvie bbenvie at mozilla.com
Mon Sep 30 19:56:09 PDT 2013


On 9/30/2013 7:34 PM, Matthew Robb wrote:
> var f = function(a=this){}
>
> would transpile to something like:
>
> var f = (function(){
>
> function __funcHead__(){
> a=this;
> }
> function __funcBody__(){
> // do stuff
> }
>
> var a;
>
> return function(a){__funcHead__.apply(this, arguments);return 
> __funcBody__.call(this)}
>
> }());
>
> If my interpretation is correct.
>

Not exactly. We're talking about lexical scopes, not function scopes. 
|this| applies at the function scope (aside from global and arrowfunc 
scope).


More information about the es-discuss mailing list