js precompiled part of the variable lift

Some things need to tell you how to use, go to understand the definition 

Promotion About variable 
function the Test () { 
  console.log (A) 
  var A = 100 
  console.log (A) 
}; 
the Test () // undefined // 100 
execution step
 function Test () {
   var a = undefined 
  the console.log (a) 
  a = 100 
  the console.log (a) 
} 

to enhance a function of the 
function Test () { 
  the console.log (a) 
  function a () {} 
  the console.log (A) 
  function B () {} 
  the console.log (B) 
}; 
Test () //function a () {} // function a () {} // function b () {} 
step
 function Test () {
   var A = undefined
   var B = undefined 
  A = function A () {} 
  B = function B ( )} { 
  the console.log (a) 
  the console.log (a) 
  the console.log (B) 
} 

mixed on variables and functions to enhance the 
function Test () { 
  the console.log (a) 
  var a = 100 
  the console.log (a) 
  function A () {} 
  the console.log (A) 
  function B () {} 
  the console.log (B) 
}; 
Test ()// function 100 // 100 // // A function B () {} () {} 
step
 function Test () {
   var A = undefined
   var B = undefined 
  A = function A () {} 
  B = function B ( )} { 
  the console.log (A) 
  A = 100 
  the console.log (A) 
  the console.log (A) 
  the console.log (B) 
} 

on the mixing parameter variables and lifting 
function Test (A) { // with defined functions this parameter is received parameter 
  the console.log (A)
   var A = 100 
  the console.log (A) 
}; 
//Function call specific parameters passed when the parameter is the argument 
Test (. 1) // . 1 // 100 
executes step
 function Test (a) {
   var a = undefined 
  a = a // right is a parameter 
  console.log ( a) 
  a = 100 
  the console.log (a) 
} 

mixed on the parameter and functions to enhance the 
function Test (a) { 
  the console.log (a) 
  function B () {}
   function a () {} 
  the console.log (a) 
  the console.log (B) 
}; 
Test ( . 1) // functioin A () {} // function A () {} // function B () {} 
step
 function Test (A) {
  var a = undefined
   var B = undefined 
  a = a // right is a parameter 
  B = function B () {} 
  a = function a () {} 
  the console.log (a) 
  the console.log (a) 
  the console.log (B) 
} 

mixed on parameter variables and functions, and to enhance the 
function Test (a) { 
  the console.log (a); 
  var a = 100 ; 
  the console.log (a) 
  function a () {} 
  the console.log (a) 
  function B () {} 
  the console.log (B) 
}; 
Test ( . 1) //function a () {} // 100 // 100 // function b () {} 
step
 function Test (a) {
   var a = undefined
   var B = undefined 
  a = a // right is a shape parameter 
  a = function A () {} 
  B = function B () {} 
  the console.log (A) 
  A = 100 
  the console.log (A) 
  the console.log (A) 
  the console.log (B) 
} 

IF judged not affecting variable lift (IF the statements are executed, and the variable lift links belonging precompiled; JS compiled before execution)
 function Test () { 
  the console.log (A) 
  IF ( to false ) {
     var= 100 A 
    the console.log (A) 
  } 
}; 
Test () // undefined 
step
 function Test () {
   var A = undefined 
  the console.log (A) 
  IF ( to false ) { 
    A = 100 
    the console.log (A) 
  } 
} 


summary: 
internal function js precompiled aspect is performed in the following order
 1 the parameter, variable, function variables corresponding to the top of the function (performed in the context of the top).
 2 the parameter, the function assigned to the corresponding variables (. the first parameter, the function) 
3. executed sequentially   

 

Guess you like

Origin www.cnblogs.com/guozongzhang/p/11022932.html