On Tue, Sep 11, 2012 at 1:36 AM, Brendan Eich <[email protected]> wrote:

> Dmitry Soshnikov wrote:
>
>> var FOO = 42;
>> function bar(x, y = FOO + z) { var z = 10; } // Error .. ?
>>
>
> Translating to JS as it is:
>
>   var FOO = 42;
>   function bar(x, y) {
>     if (y === void 0) y = FOO + z;
>     var z = 10;
>   }
>
> No error expected, undefined hoisted z used in FOO + z resulting in y
> defaulting to NaN if y is not passed or given actual undefined value in a
> call.
>
>
Ah, OK, so then it's just evals as a casual local var/parameter (in
activation + bar.[[Scope]]) and that's it. And there probably will not be a
confusion.

Yes, this one may be better than just outer scope. Sorry, I thought about
some more complicated stuff (first outer, then inner). If this is the same
as a casual local var resolutions, then it's OK.

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

Reply via email to