Is ES5 Strict a fully statically scoped language?

Brendan Eich brendan at mozilla.org
Wed Oct 3 17:08:13 PDT 2012


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
> }
> }());


More information about the es-discuss mailing list