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.