4 ms·
tldr version, minus the usual stackoverflow backandforth: Named elements are made into properties of the "window" object in Chrome, IE, and Opera. That would
by pak 15y ago
tldr version, minus the usual stackoverflow backandforth:
Named elements are made into properties of the "window" object in Chrome, IE, and Opera. That would include any element with an "id" attribute and most elements with a "name" attribute. Thankfully, any vars you declare in this scope override the DOM ones.
With some quick testing in Chrome, IE, and Opera, it appears that these elements are enumerable off of "window" in Opera but not Chrome and IE (perhaps those two browsers create them only when you access them).