Javascript Boolean object

Source: Internet
Author: User

Boolean objects are simple but useful, but are also listed as a chapter.

The Boolean object is similar to the Boolean encapsulation class in Java. It has two values: true and false.
1. Create a Boolean object
Var boo = new Boolean (); // boo is not assigned at this time, but its default value is false.
Var boo = new Boolean (true );
Var boo = true/false;
2. the constructor attribute of the Boolean object is Boolean.
Example:
Var boo = new Boolean ();
Document. write (boo. constructor = Boolean );
Document. write ('<br> ');
Document. write (boo );
Output result:
True
False
Description: its constructor attribute is Boolean.
If the initial value is not assigned to it, its value is false.
3. The toString () method returns the string corresponding to the Boolean object.
True ---> true;
False ---> false;
Var boo = new Boolean ();
Document. write (boo );
Document. write ('<br> ');
Document. write (boo. toString ());
Output:
False
False
The output results of these two methods are the same, which is somewhat similar to the output of some classes in Java.

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.