Example application of false values for exotic flowers in JavaScript

Source: Internet
Author: User

  This article mainly introduces the false value application of the wonderful flower in JavaScript, the friend who need can refer to the following

Usually in the following statement structure needs to determine true and false     If branch statements   while Loop statement   for the second statement of the    , such as the     code as follows: if (boo) { / /do something }    while (boo) { //Do something }    JavaScript 6 values are "false", these six values are &nbs P   false  null  undefined  0  ' (empty string)   nan    This false itself is a Boolean type, and the other 5 are not.     In addition to these 6, the other is "true", including objects, arrays, regular, functions and so on. Note that ' 0 ', ' null ', ' false ', {}, [] are also true values.     Although these six values are "false", they are not all equal   code as follows: Console.log (false = null)//false  Console.log (false = = Undefine d)//false  Console.log (false = = 0)//true  Console.log (false = = ")//true  Console.log (false = = NaN)//false    Console.log (null = = undefined)//true  console.log (null = 0)//false  Console . log (Null = =)//false  console.log (null = = NaN)//false    console.log (undefined = 0)//FALSE&N Bsp Console.log (undefined = = ")//false  console.log (undefined = = Nan)//false    console.log (0 = ")//true  console.log (0 = = Nan)//false    for" = = ", above come The following conclusions     False is true only if compared to itself, and 0, ' is also true  null compared to undefined, and vice versa undefined is only null comparison to True, without a second   0 In addition to false to true, there is also an empty string '   empty string ' out and false compared to true, there is also a number 0 
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.