See code Example 1
varA=1; functionM (a) {//here is the parameter of the first incoming function of the formal parameter, both arguments[0]alert (a);//where a is bound to a formal parameter} m (a);//1 A In this case passes the variable a as a parameter to the function....................................................................................................... varA=1; functionm (a) {alert (a); } m ();//Undefind is bound to a function as null because there are no parameters passed in, so alert a undefined
code Example 2
var a=1; function m () {// alert (a); alert (b); function n () { var a=5; var b=3; // m (); } n (); // alert A is 1, to the B-times wrong is not defined m (); // alert A is 1, to the B-times wrong is not defined
The visible function m, when created, has bound itself to the scope of the creation environment, where it is a global scope, and when called in function N, it does not look for a variable in the private scope of function n, so the function n defines
A and B do not appear in the scope chain of the function m, as shown in the comments in the code.
code example 3
var a=1; function m (a) {///A In this case and a in the function are formal parameters and have no relation to the a variable declared in the first line, they have no binding relationship in Instance 2 alert (a); } function N () { var a=5;// M (a);//The variable A is passed into function m, and when alert A is required, the value of a is alert, } N (); // 5 M (); // Undefind
Here the difference is due to the differentiated participation variable.
The scope of the anonymous function is more complex, wait for a good sleep and then get up and tidy up.
JavaScript's understanding of semantic functions