The false value of a wonderful flower in JavaScript

Source: Internet
Author: User

There are 6 values of "false" in JavaScript, and these six values are:

    1. False
    2. Null
    3. Undefined
    4. 0
    5. "(empty string)
    6. NaN

In this case, false itself is a Boolean type, and the other 5 are not.

In addition to these 6, the others are "true", including objects, arrays, regular, functions, and so on. Note that ' 0 ', ' null ', ' false ', {}, [] are also true.

Although these six values are "false", they are not all equal:

1Console.log (false==NULL)//false2Console.log (false= = undefined)//false3Console.log (false= = 0)//true4Console.log (false= = ")//true5Console.log (false= = NaN)//false6 7Console.log (NULL= = undefined)//true8Console.log (NULL= = 0)//false9Console.log (NULL= = ")//falseTenConsole.log (NULL= = NaN)//false One  AConsole.log (undefined = = 0)//false -Console.log (undefined = = ")//false -Console.log (undefined = = NaN)//false the  -Console.log (0 = = ")//true -Console.log (0 = = NaN)//false

for "= =", the following conclusions are drawn:

    • False except that compared to itself is true, and 0, "" is also true
    • Null is only true when compared to undefined, in turn undefined only and null are compared to true, without a second
    • 0 except and false compare to true, there is an empty string "'" and an empty array []
    • The empty string ' In addition to false compares to true, there is also a number 0

Reference connection: http://www.cnblogs.com/snandy/p/3589517.html

The false value of a wonderful flower in JavaScript

Related Article

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.