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.
P.S.: Though, it still seems that the parent-only scope fits better
since avoids complexities. Otherwise, we'll get yet another
interesting quiz questions like this one:
var x = 10;
(function foo() {
console.log(x); // undefined?
var x = 20;
})();
This case has *nothing* to do with default parameters. The answer is of
course undefined and we can't change that. I'm not sure why you bring it up.
/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss