Skip to content Skip to sidebar Skip to footer

How Did 'name' Become A Global Variable?

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,

Solution 1:

name is a property of the window object, and like all other members of window, it's accessible globally.

Solution 2:

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>");

Post a Comment for "How Did 'name' Become A Global Variable?"