| home / programming / java_core / 2 | [previous] [next] |
|
|
The Boolean object was included in JavaScript 1.1. It is used to convert a non-Boolean value to a Boolean value, either true or false. There is one property, the prototype property, and one method, the toString() method, which converts a Boolean value to a string; thus, true is converted to "true" and false is converted to "false".
|
<html><head><title>Boolean Object</title> <font face="arial" size="+1"><b> <script language="JavaScript"> var bool4 = new Boolean(null); 2 document.write("The value 0 is boolean "+ bool1 +"<br>"); document.write("The value 1 is boolean "+ bool2 +"<br>"); document.write("The value of the empty string is boolean "+ document.write("The value of null is boolean "+ bool4+ "<br>"); document.write("The value of NaN is boolean "+ bool5 +"<br>"); |
|
|
|---|
The argument passed to the Boolean object constructor is the initial value of the object, either true or false. If the initial value is 0, the empty string "", NaN, or null, the result is false; otherwise, the result is true. |
| home / programming / java_core / 2 | [previous] [next] |
| ||||||||||||||||||||
Created: March 27 2003
Revised: November 19, 2003
URL: http://webreference.com/programming/java_core/2