Copy Code code as follows:
var A; Declare a variable with an identifier of a
function A () {//Declaration of functions, identifiers also for a
}
Alert (typeof a);
Displays "function", which means that the function has precedence over var.
Some people think that this is the reason for the sequential execution of code, that is, a is covered by the funcion of execution. Well, switch them.
Copy Code code as follows:
function A () {
}
var A;
Alert (typeof a);
The results still show "function" rather than "undefined". That is, the function declaration takes precedence over the variable declaration.
We modify the code slightly and declare a while assigning a value.
Copy Code code as follows:
function A () {
}
var a = 1; Note here
Alert (typeof a);
This shows "number" but not "function", which is equivalent
Copy Code code as follows:
function A () {
}
var A;
A = 1; Note here
Alert (typeof a);
That is, "var a = 1" split into two steps. A is assigned a value, and nature is the last one.