[Js]js 4 types of moral integrity-free pre-interpretation

Source: Internet
Author: User

4 kinds of pre-interpretation without moral integrity in JS
- 1. if语句即使条件不成立,条件里的表达式也会进行预解释.- 2. 匿名函数的预解释:  只对等号左边与解释- 3. 自执行函数的预解释: 不进行预就解释, 执行的时候,定义+执行- 4. return下面的语句也会进行预解释,但是return后面的语句不进行预解释
  <script> var p1 = {name: "Maotai"}; Console.log (age);    1. Even if the condition is not established, the expression in the condition will be pre-explained.        if (' Age ' in p1) {//is an attribute of the object var age = 22;    Console.log ("name in P1")} console.log ("--------------------------------");    2. Pre-interpretation of anonymous functions: only to the left of the equals sign with the explanation FN ();    function fn () {Console.log ("FN is running!");    } fn ();    Console.log ("--------------------------------");    The right side of the equals sign is not pre-interpreted. FN2 ();        Error var fn2 = function () {var favor = "Orange";    Console.log ("Fn2 is running!")    };    FN2 (); 3.    Pre-interpretation of self-executing functions: Do not pre-interpret, execute, define + Execute ~function (num) {console.log ("I am zi Zhi xing fun" + num);    } (100);    4, return the following statement will also be pre-explained, but return after the statement is not pre-interpretation console.log ("--------------------------------");        function Fn3 () {console.log (num3); return function () {};         This function does not perform with the explanation of var num3 = 330; This will be pre-explained} fn3 (); </script>  

[4 Non-moral integrity pre-interpretations in Js]js

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.