Automatically created variables from ids in JS?
<p>Just today after a couple of years of javascript programming i come across something that left me startled. Browsers create objects for every element with an id. The name of the object will match the id. </p>

<p>So if you have:</p>

<pre><code>&lt;div id ="box"&gt;&lt;/div&gt;
</code></pre>

<p>You can do:</p>

<pre><code>alert(box); //[object HTMLDivElement]
</code></pre>

<p>Without first assigning anything to that variable. <a href="http://jsfiddle.net/JLt3y/" rel="nofollow">See the demo</a>.</p>

<p>This for some reason seems to be <a href="http://www.whatwg.org/specs/web-apps/current-work/#dom-window-nameditem" rel="nofollow">in the standards</a> even though it can break the code in <a href="http://www.west-wind.com/weblog/posts/2009/Mar/22/Internet-Explorer-Global-Variable-Blow-ups" rel="nofollow">some cases</a>. There is an <a href="http://www.w3.org/Bugs/Public/show_bug.cgi?id=11960" rel="nofollow">open bug</a> to end this behavior but i'm more interested in getting rid of it now. </p>

<p>Do you guys know if there is a way to disable this (<a href="https://developer.mozilla.org/en/JavaScript/Strict_mode" rel="nofollow">strict mode</a> maybe)? am i giving this too much importance? because it certainly seems like a bad idea. (It was introduced by IE to give you a hint).</p>

<p><strong>Update:</strong> It seems FF only does this in quirks mode. Other browsers like IE6+ and Chrome do it right off the bat.</p>
