The difference between null and undefined

Source: Internet
Author: User

Null indicates that an object is defined with a value of " null ";

Undefined indicates that this value does not exist.

//

typeof undefined

"Undefined"

Undefined: is a primitive value that represents " none " or " missing value ", thatis, there should be a value here, but it is not yet defined. Undefined is returned when attempting to read;

For example, when a variable is declared but not assigned, it is equal to undefined.

typeof null

"Object"

Null: is an object ( empty object , without any properties and methods );

For example, as an argument to a function, the argument to that function is not an object;

Note: When validating null , be sure to use = = = , because = = cannot be null and undefined separately

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.