Variable declarations inside with statements

P T Withington ptw at pobox.com
Mon Jul 7 14:29:47 PDT 2008


On 2008-07-07, at 17:01 EDT, Brendan Eich wrote:

> <script>
>     var x = 42;
>     var o = {x:33};
>     with (o)
>         var x = 21;
>     alert('var x is ' + x + ', o.x is ' + o.x);
> </script>
>
> alerts "var x is 42, o.x is 21" in Firefox, Opera, and Safari.

Nice to see so many implementations followed the spec., but... ouch!   
I bumped my head on that silly `var`.




More information about the Es4-discuss mailing list