JS---Pre-parsing, declaring elevation

Source: Internet
Author: User

<! 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.