Variable lift and enhance the function :
It is to declare a variable or function to enhance the entire code section to the beginning of the current scope (global scope or function scope).
JavaScript function field in the range of the minimum domain; "{}" is not scope for loops, while loops, if statements, switch statement.
A variable lift:
variables var declared in advance to the starting position of the current scope, is declared. In situ assignment.
1 form referred to: var a = "lift"; (Keywords are "var")
2. enhance manner: "var a", to the top of the current scope, a = "lift", defined position in the prototype.
3. Specific codes:
eg:
II. Functions lift
1. The function of the form referred to lift: function fn () {......} (function declaration must be in the form, not in the form of function expression).
2. The function of lifting manner: "function fn () {......}" whole function declaration code block to the top of the current scope,
Original location to the absence of the code.
3. All function using the function statement, will enhance the overall scope statement as long as the current number
Can be used in any location, type an assignment to create a function to enhance the statement is not.
When the function and the same name as a variable, the variable lift higher, to enhance the function of the following variables
Cause the value of the function to take effect
There;
function a(){}
console.log(a);
a = 10;
eg:
function fn(){
After lift equivalent to the formula