JavaScript Boolean type Object _ Basics

Source: Internet
Author: User

The Boolean object is similar to the Boolean package class in Java, and it has two values: True and False

1. Create a Boolean object

Copy Code code as follows:
var boo = new Boolean ()//The Boo is not assigned at this time, but its default value is False
var boo = new Boolean (true);
var boo = True/false;

2, the Boolean object's constructor property is a Boolean

Cases:

Copy Code code as follows:
var boo = new Boolean ();
document.write (Boo.constructor==boolean);
document.write (' <br> ');
document.write (Boo);

The output results are:

True
False

Description: Its constructor property is Boolean
If it is not assigned an initial value, it is false

3, ToString () method, returns a Boolean object corresponding to the string

True--->true;
False--->false;

Copy Code code as follows:
var boo = new Boolean ();
document.write (Boo);
document.write (' <br> ');
document.write (Boo.tostring ());

Output:

False
False

The output of these two methods is the same, somewhat similar to the output of some classes in Java

See more JavaScript syntax, you can focus on: JavaScript reference tutorial, JavaScript Code style guide, and also hope that many people support the cloud-Habitat community.

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.