JS Beginner Some of the error-prone knowledge points

Source: Internet
Author: User

1. False, 0, "", Undefined, NULL in Boolean environment as false;

Null is treated as 0 under the numerical environment;

Undefined is considered as NaN under numerical environment;

2.NaN cannot participate in comparison, Nan = = Nan result false

3. (1) non-changing value: Number, String, Boolean, undefined, null

Features: The value 12 is stored in the stack, when a variable is re-assigned to the value of 13 o'clock, the system will change the name of the original address to the original number, the number of the next address to the name of the variable, and the re-assigned value of 13 to the next address, and the original number of the address stored in the original value of 12,

(2) Citation: array,objict, function

Features: The referenced address is stored in the stack, and the corresponding value is stored in the heap, var a = [0,1]; var B = [+]; If you make a = B; The end result is that both A and B point to the address of a, and the number of elements in a B is exactly the same as the size.

The 4.web standard (a standard for the one), structure, style, behavior separation, CSS and JS are usually introduced externally.

5. When executing the code, CSS takes the form of asynchronous parsing of HTML code while parsing the CSS code while performing

JS using synchronous mode, when the resolution encountered JS code or JS introduced, will be the full load of JS code parsing will be parsed after the HTML and CSS code.

6.&& and | | Small differences from other languages

1 && 2, first execute 1, if 1 is false, then return false directly, no longer see 2;

If 1 is true, then look at 2 and finally return a Boolean value of 2.

1 | | 2, the first execution 1, if 1 is true, then directly return true, no longer see 2;

If 1 is false, then look at 2 and finally return a Boolean value of 2.

Precautions: For example (i). 1 && 2 return 2,

(b). 0 && 2 returns 0.

|| In the same way as &&, if the participating judge is not a Boolean type or a logical expression, then 0, undefined, null, "" is judged as false, but the returned value is still not the original value, not the Boolean value that participates in the judgment.

7. +,-,/, *, = write code preferably with a space on both sides, so that the code conforms to the specification. For example: 1 + 2 = 3;

8. Declaring Variable Specifications:

(1) Use Var to declare almost all types of variables.

(2) Variable name: can only contain letters, numbers, _, dollar sign, and cannot start with a number; letters are case-sensitive.

JS Beginner Some of the error-prone knowledge points

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.