Answers for "javascript global variable across files"

1

javascript global variable across files

var window.iAmGlobal = "some val"; //Global variable declaration with window.
 
//Any place in other part of code
 
function doSomething()
{
    alert(window.iAmGlobal); //I am accessible here too !!
    //OR
    alert(iAmGlobal); //I am accessible here too !!
}
Posted by: Guest on August-17-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language