JavaScript Advanced Programming Reading notes

Source: Internet
Author: User

If you put all the script elements in the head element of the page, it means that you must wait until all the JS code is downloaded, parsed, and executed before you can begin rendering the contents of the page. For those pages that require a lot of JS code, there is a noticeable delay when the browser renders the page, and the browser window will be blank during the delay. To avoid this problem, the JS reference is generally placed behind the content of the page in the BODY element.

First, the basic concept

1, if the defined variable is to be used to hold the object in the future, it is better to initialize the variable to null instead of the other value. This allows you to know whether a variable of the response holds a reference to an object, as long as you check the null value directly.

2, for those large or small values, you can use the E notation (scientific counting method). 3.12e5<=>312000,3.12e-5<=>0.0000312. Floating-point numeric calculations produce rounding errors.

var a=0.2,b=0.1; a+b; // 0.30000000000000004

3, logic and logic or operators are short-circuiting operators (if the first operand can determine the result, the second operand is no longer evaluated)

var x=true;x&&y; // Error var x=false;x&&y; // false var x=false; x| | Y // Error var x=true; x| | Y // true

Use logical or short-circuit behavior to avoid assigning null or undefined values to variables

var a=null; var b=a| | {x:1};b; // Object {x:1}

4, the operator will convert the operand data.

' One ' > ' 2 '; // False, string comparison character encoding ' one ' >2; // true

When comparing strings, the actual comparison is the character encoding value for each character in the corresponding position of two strings. When you compare alphabetic strings in alphabetical order (<,>), you must convert two operands to the same case (uppercase characters are all smaller than lowercase letters)

5,js does not have a function overload, multiple functions with the same name, and a function that is defined later overrides the first defined function.

JavaScript Advanced Programming Reading notes

Related Article

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.