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.