W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2012

Re: variable declarations shadowing named properties on window

From: Cameron McCormack <cam@mcc.id.au>
Date: Wed, 04 Jan 2012 14:21:37 +1100
Message-ID: <4F03C5C1.90303@mcc.id.au>
To: Ojan Vafai <ojan@chromium.org>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>, Boris Zbarsky <bzbarsky@mit.edu>, Travis Leithead <Travis.Leithead@microsoft.com>, Allen Wirfs-Brock <allen@wirfs-brock.com>, Ian Hickson <ian@hixie.ch>
Ojan Vafai:
> Firefox behaves differently for frames and elements I believe (or maybe
> names versus IDs?).
>
> <div id="a"></div><script>alert(a);</script> // Alerts "[object
> HTMLDivElement]"
> <div id="a"></div><script>alert(a);var a;</script> // Alerts "undefined"
> <div id="a"></div><script>var a;alert(a);</script> // Alerts "undefined"

Note that the last two should always be the same because property 
creation due to var statements is handled first before the script is run.
Received on Wednesday, 4 January 2012 03:24:48 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:05 UTC