This question ( Element accessible with ID ) points out that if an element has an id then you can access it by variable name based on that id. It intrigued me, as I had seen this variable available when developing using Visual Studio 2010. I did some testing out of curiosity and it turns out that document.getElementById()
was still faster than using the variable name. So, I began trying to look through the window, figuring it must be in window["idName"]
, in debug, and with console.log(window)
and could not find where the variable was actually stored.
When an element is defined in html with <div id="foo">
it is available in javascript with the variable foo
(I am not suggesting to use this, it is bad practice). Where is that variable stored?