JS Some if statement to determine the condition is fasle case

Source: Internet
Author: User
JS Some if statement to determine the condition is fasle case

Prior to write an if judgment condition produced by the bug, when the Write logic processing data is in the background to the interface before, so I developed a field value of number type 0 or one to judge, the last interface comes out of the time is a string, whether 0 or 1 is true. Number of type 0, the Boolean value is false,string type of 0, and the Boolean value is true. So here's a case where you want to count some data types for conditional judgments.


Here you can see the empty string as the result of the judgment is false


Here you can see that the number type is only 0 as the judgment result is false


Here you can see NaN, undefined, and null as a result of false


Here a method is added to determine if the variable is undefined typeof b = = "undefined" If undefined return result is true, the defined result is false

JS Some if statement to determine the condition is fasle case

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.