The same identifier is declared with var and function successively. What is it?
The Code is as follows:
Var a; // declare a variable with the identifier
Function a () {// declare a function. The identifier is.
}
Alert (typeof );
"Function" is displayed, that is, the priority of a function is higher than that of var.
Some people think this is the reason for sequential code execution, that is, a is overwritten by the funcion executed later. Okay. change them.
The Code is as follows:
Function (){
}
Var;
Alert (typeof );
The result still shows "function" instead of "undefined ". That is, function declaration takes precedence over variable declaration.
We make a slight modification to the code and assign values when declaring.
The Code is as follows:
Function (){
}
Var a = 1; // note that
Alert (typeof );
"Number" is displayed but not "function", which is equivalent
The Code is as follows:
Function (){
}
Var;
A = 1; // note that
Alert (typeof );
Split "var a = 1" into two steps. A is re-assigned, which is the final value.