Pre-resolving process:
1. declare variables var raised to the current scope of most front, the assignment will not improve
2. Declaring functions and drop the Pirates to enhance the scope of
3. If the function of the same name, which will be covered by the former
4. If the functions stated var stated and the same name, the priority function
Case:
1.
<script> var num = 10; fn1(); function fn1() { console.log(num) var num = 20 } </script>
After the pre-parsing:
<script> var num = 10; function fn1() { var num console.log(num) //10 num = 20 } fn1(); </script>
Print result: undefined
2.
<script> fn(); console.log(c); console.log(b); console.log(a); function fn() { var a = b = c = 9; console.log(a); console.log(b); console.log(b); } </script>
After the pre-parsing:
<Script> function Fn () { var A = . 9 ; // local B = . 9 ; // implicit global C = . 9 ; // Implicit Global the console.log (A); the console.log (B); Console. log (C); } Fn () the console.log (C); the console.log (B); the console.log (A); </ Script>
Print Results:
99999 error