<! DOCTYPE html>//pre-parsing, variable declaration promotion if(! Ainchwindow) { varA=123; } alert (a);//undefined /*Description: * 1. Variable declaration promotion, var A; * 2. Variable A is a member of the Window object and the If condition is false, so the assignment statement is not executed. * 3. The last printed a is undefined, because a declares that the clam is not assigned a value. *///function declaration promotion, although the function is written in the back, but the declaration will raise Foo ();//1 function foo () {alert (1); }//If statement in the function if (true) {function f1 () {console.log (' true '); }}else{function F1 () {Console.log (' false '); }} f1 ();//true//Description: In the new version of the browser, the function written in the logical judgment block is treated as an expression, not as a function declaration, so there is no problem of function elevation. </script>
JS---Pre-parsing, declaring elevation