The same identifier is declared with VAR and function successively. What is it?
VaR A; // declare a variable with the identifier afunction A () {// declare a function with the identifier a} alert (typeof );
"Function" is displayed, that is, the priority of a function is higher than that of var.
Some people think this isCodeThe reason for sequential execution is that A is overwritten by the funcion executed later. Okay. change them.
Function A () {} var A; 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.
Function A () {} var A = 1; // note alert (typeof A) here );
"Number" is displayed but not "function. If you place the VaR declaration statement at the top, the result is the same.
VaR A = 1; // note that function a () {} alert (typeof );
This is equivalent
Function A () {} var A; A = 1; // note alert (typeof A) here );
Split "Var A = 1" into two steps. A is re-assigned, which is the final value.