Does the DOM have a hash-table of elements whose keys are the elements\' ids?
I want to know if document.getElementById
looks up a hash table or traverses t
The specific implementation isn't defined in the HTML spec so it could easily vary browser to browser. For example IE documentation states
Returns a reference to the first object with the specified value of the ID or NAME attribute.
so I'd be tempted to say it does a search (or it just throws out elements in cases of hash collisions).
EDIT Also keep in mind there are other data structures (like trees) that allow for access time somewhere between constant and linear.