Friday afternoon scoping quiz

P T Withington ptw at
Sat Feb 6 06:49:33 PST 2010

On 2010-02-05, at 18:08, Dmitry A. Soshnikov wrote:

> Scope chain (test): [
>  global,
>  {foo: undefined, bar: undefined},
>  {foo: 20, test: function () {...}}
> ]

This is the key that I was missing, as Brendan made clear.  Despite `foo` and `bar` being declared inside the `with`, because declarations are hoisted, the `var foo` is shadowed by the `with (this)` when the assignment `foo = 42` is evaluated.

Thanks for the clarifying illustrations.

More information about the es-discuss mailing list