The type of JavaScript to judge (a) True and false

Source: Internet
Author: User

Absrtact: The main purpose of this article is to help me to comb the context of JavaScript learning and use, most of it is only the collation of learning content, rather than original, I will post a reference link at the end of the article.

6 of the values in JavaScript are false

    1. False
    2. Null
    3. Undefined
    4. ‘‘
    5. 0
    6. NaN

The difference between = = = and = =

    • = = =, do not type conversion, different types of certain range.
    1. "Unequal" if the types are different
    2. Type the same, and then judge

    • = =, when the value types on both sides are different, type conversion is performed before comparison.
    1. If the two value types are the same, the = = = comparison.
    2. If two value types are different, they may be the same. The conversions are then compared according to the following rules:

A. If one is null and one is undefined, then "equal"

B. If one is a string, one is a numeric value, the string is converted to a value and then compared

C. If a value is Boolean, Boolean converts to a value of 1, and then compares

D. If one is an object and the other is a numeric or string, convert the object to the underlying type and then compare it. The object is converted to the underlying type, using its toString or ValueOf method. JS core built-in class, will try to valueOf before ToString, the exception is data, data is using the ToString conversion:

E. Any other combination, "unequal"

    • Determines whether a value is NaN and can only be judged by IsNaN ()

= = = or = =

Should you use "= =" or "= = =" in JavaScript?

Reference

1. The difference between 2 equals and 3 equals sign in JavaScript

The type of JavaScript to judge (a) True and false

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.