How to access javascript gobal variable using window object? Write example

Any global variable declared outside the function in Javascript get
attached or added to window object.
Ex:
var myvar = 5;
function myFunction()
{
alert(window.myvar);// gives 5
window.myvar = 100;
alert(window.myvar);// gives 100
}

No comments:

Post a Comment