A concise comparison of NULL, undefined, and Nan

Source: Internet
Author: User


The null type also has only one value, which is null. Null is used to represent an object that does not already exist, and is commonly used to indicate that a function is attempting to return a nonexistent object.
The Undefined type has only one value, which is Undefined. When the declared variable has not been initialized, the default value for the variable is undefined.
NaN type represents non-numeric

Difference:
1, NULL is the reserved keyword of js, undefined and Nan are (Global object) a special property of window (the target in window is ture), not the keyword
2, typeof null is object,undefined for Undefined,nan, can be understood as NULL is a special object, Nan is a special number
3, participate in the numerical calculation: null value is 0 added to the calculation, undefined and Nan participate in the calculation results are Nan.
4, null==undefined, but not = = =;
5. The DOM tries to get the element that does not exist return null

A concise comparison of NULL, undefined, and Nan

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.