It's funny, yes, in IE? (I have 8th).
someItem = document.getElementById('someItem')
This code gives an error. What kind of dumb programmer has banned the use of a variable that matches the element id ?? Or am I misunderstanding something?
What you call a global variable is not. The execution of the script goes in the context of the window (the window object). Assigning (without var)
x = 0 creates a property on the window object with the name x. In IE (and for some time in other browsers) all elements of the document with the specified id are available as "global" variables, i.e. as properties of the window object. The fact that the error occurs only in IE8, and, for example, in IE9, your assignment works as you would expect - this is only an implementation in a specific browser version. In version 8, when you try to overwrite a property that points to a DOM element, an exception is thrown; the setter is not implemented just apparently.
Try this code:
alert = 0;
Yes, IE8 will produce the same error. In IE9 and other alert browsers it will no longer work and will cease as expected to be a function.
Threat Why use these "global" variables is bad, I think, understandable.
ZZY But the IE developers do not have to kick, they have already been cursed by several generations of web developers, there is no difference from another curse.