2) local and global variables
Mark -to-win: inside the browser window is global, you can usually save.
nodejs There is no window, but the man named global.
Example 3.2.1
<HTML>
<head>
<Meta HTTP-equiv = "Content-type" Content = "text / HTML; charset = UTF-. 8" />
</ head>
<Script>
/ * Mark -to-win : there are no var var, the function is the same as outside, are global, which function at the time, var is local, no time is the representative global var * /
var testvar = "total amount";
document.writeln ( " IS window.testVar "+ + window.testVar testvar);
var testqVar =" total amount Q ";
/ * if not shield the sentence, in which the program is directly stopped due to errors, do not know testGlobal, to obtain the next sentence and under a change in the position of the next sentence, the ok * /
// document.writeln ( "testGlobal IS" + testGlobal);
testGlobal = "full amount, Ltd. Free Join";
document.writeln ( "abc IS" + Abc);
The ABC;
testGlobalInVar = "total amount globalInVar";
function testSco ()
{
var LLL = "QQQ";
var testvar = "Board amount"; // outside this testvar non testvar
testqVar = "total amount qchange"; // this testqVar is outside testqVar
testGlobal = "total amount globalchange";
var testGlobalInVar = "Board amount global"; // this non testGlobalInVar outside testGlobalInVar
/ * local variable iS Stronger Within last Global variable.so "testvar" the following Statement means in local variable * /.
Document. writeln (testvar);
document.writeln (testqVar);
document.writeln ( "IS testGlobalInVar" + testGlobalInVar);
}
testSco ();
document.writeln ( "second test is " + testVar);
document.writeln("second testqVar is " + testqVar);
document.writeln("testGlobal is " + testGlobal);
document.writeln("testGlobalInVar is " + testGlobalInVar);
</script>
See more: https://blog.csdn.net/qq_44594249/article/details/99864142