Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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 !!
}
 
PREVIOUS NEXT
Tagged: #javascript #global #variable #files
ADD COMMENT
Topic
Name
3+7 =