Null, empty objects, and undefined

Source: Internet
Author: User

null: Is an object, but a null reference (not pointing to any object)

Empty Object : is an object, but its value is a reference to an object that does not have any properties

undefined: Undefined, so not an object, which itself is defined as a special type of "undefined"

1. When null participates in numeric operations, its value is automatically converted to 0, so the following expressions are evaluated to get the correct values:

Expression: 123 + null result value: 123

Expression: 123 * Null result value: 0

2. When undefined participates in any numerical calculation, the result must be Nan.

3. Alert (typeof undefined); //output "undefined"

Alert (typeof null); //output "Object"

Alert (null = = undefined); //output "True" ECMAScript that undefined is derived from null, so define them as equal

Alert (null = = = undefined); //output "false" = = = Absolute equals

Alert (typeof null = = typeof undefined); //output "false"

Null, empty objects, 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.