Basic knowledge of Boolean objects in JavaScript programming

Source: Internet
Author: User

A Boolean (Boolean) object is used to convert a non-Boolean value to a Boolean value (True or false).

Checking Boolean values
Check whether the Boolean object is True or false.
Source code Example:

<! DOCTYPE html>
 
 

Test results:

0 is a Boolean false
1 is boolean true a
empty string is Boolean false
null are Boolean false
NaN is Boolean False the
string ' false ' is Boolean true

Create a Boolean object
a Boolean object represents two values: "True" or "false"
The following code defines a Boolean object named Myboolean:

var myboolean=new Boolean ();

If the Boolean object has no initial value or its value is:

0
-0
null
""
false
undefined
NaN

Then the value of the object is false. Otherwise, the value is true even when the argument is string "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.