You should eval an initialized var declaration of foo inside the with,
and check foo's value after the with body, for real head-exploding. ;-)
/be
Šime Vidas wrote:
Well, thank you for your excellent video. The dynamic scopes in the
default language are a disaster... I've just written a short code
example (see below) which demonstrates this. Thank goodness ES5 Strict
is statically scoped. :-)
// global code
this.foo = 1;
(function () {
eval('var foo = 2');
with ({ foo: 3 }) {
foo // => 3
delete foo;
foo // => 2
delete foo;
foo // => 1
delete foo;
foo // ReferenceError
}
}());
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss