This question already has an answer here:
Why is it that assigning a DOM element to the global variable "name
" doesn't work ?
This question already has an answer here:
Why is it that assigning a DOM element to the global variable "name
" doesn't work ?
While name by itself is a property of the window object, you may still use name with another object as follows:
Resource: MDN Talk: Reserved_Words
Most "globals" in JavaScript when running in a browser are actually properties of the
window
object (of typeWindow
).But
Window
already has aname
property, so any attempt to assign a non-string to it is going to lead to conversion to a string: the type of the assigned object will not be maintained.