📜  跨文件的 javascript 全局变量 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:31.278000             🧑  作者: Mango

代码示例1
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 !!
}