Introduction to Boolean type analysis based on JavaScript data type _ basics

Source: Internet
Author: User

Today we're talking about a Boolean type in a data type that returns True and false two literals, and it needs to be noted that the literal value is case-sensitive, meaning that all but the lowercase are just identifiers.

The following are mainly about the various data types and corresponding transformation rules:

Value with value converted to true for data type conversion to False

--------------------------------------------------------------------------------

Boolean true False

String any non-empty string "" (empty string)

Number any non 0 digit value 0 and Nan

Object any objects Null

Undefined not suitable for Undefined


--------------------------------------------------------------------------------

These conversion rules are important to understand that a Process control statement, such as an if statement, automatically performs a corresponding Boolean transformation, see the following code:

Copy Code code as follows:

var msg= "Hello World";
if (msg) {
Alert ("Valus is true");
}

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.