Reputation: 591
Okay so I'm not sure if this is just isolated to Chromes developer tools, but I was toying around with some code I was working on and I realise that a variable, meant to be local, had been created in the global name space called 'name'.
I removed the bug then opened up Chrome tools to make sure the bug had been fixed. To my surprise I type 'name' into the console and an empty string is returned. After much looking through my code, I realise this isn't caused by me, so I head over to google.com and try again. To my surprise 'name' is a global variable there. After looking around, it appears there is a global variable almost everywhere when looking with Dev tools.
My question is why?
Upvotes: 3
Views: 283
Reputation: 96
name
is equivalent to window.name
and is often used to modify the name of a window, after the window has been created.
var myWindow = window.open("","MsgWindow","width=200,height=100");
myWindow.document.write("<p>This window's name is: " + myWindow.name + "</p>");
Upvotes: 3