JavaScript code considerations

Source: Internet
Author: User

1 The line at the end of the code to add good. Reason <<javascript Advanced Programming Third Edition, page 21, line three >>

2 initialization variables should be added with default values
Because values that are not declared and declared as initialized when using typeof return undefined, if the rules are initialized to get undefined, you know that there is no declaration
VAR message;
Alert (typeof message)//undefined
Alert (typeof age)//undefined age no statement

3 If a defined variable is used to hold an object, it is best to initialize it to null, so as long as you check if NULL, you know if you have saved a reference to an object.


4 undefined = = NULL//true

5 Nan = = Nan//false
IsNaN (object), parsing method, JS Advanced Program Design Third edition 30 page fifth line

JavaScript code considerations

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.