The difference between null and undefined

Source: Internet
Author: User

It is said that the birth of JavaScript was very hasty and took more than 10 days. For this reason, regardless of the skill of the person who designs the JavaScript, the language will be flawed.

Which, NULL is actually a little chicken, it and undefined also often stirred together, let me very big head.

By looking at the information, the difference between null and undefined, I now have some understanding:

1 null represents an "None" object, when converted to a numeric value, 0;undefined is a primitive that represents "none" and is Nan when converted to a numeric value;

2 when the declared variable is not initialized, the default value of the variable is undefined;

3 null is used to denote a nonexistent object, commonly used to denote a function that attempts to return a non-existent variable;

4 undefined means "missing value"; null means "no object", that is, there should be no value at all.

The difference between null and undefined

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.