What I want is both similar to A2 and B2, but it's different in that there
is only 1 scope for the inner variable. The inner variable is just a local
variable, but it's initialized in the hoisting process with the value from
the outer scope. Initially I was thinking only about var scoped variables
but I think this should work for the let scoped variables as well. We would
need a new keyword then. Adds some complexity but at least there's only one
scope.
I didn't study the details about let scope variables in the current spec
but I understand that this should throw:
{
(function () {
x; // throws - B1 case
})();
x; // x = undefined, right? - not A1 case because it doesn't throw
let x = 10;
};
Currently in FF there's no error here, x is undefined. In Chrome there's an
error about some extended mode which, from what I understand, doesn't exist
anymore.
Currently I achieve what I want by defining a local variable whose name is
prefixed with 'local' and assigning it the value I need. It's bad if I want
to do the same in multiple execution levels. My proposal is far more
readable because it looks less weird.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss