HTML and CSS Reference
In-Depth Information
Figure 9.37 Using the toFixed() Number method: Output from Example 9.32.
9.5.6 The Boolean Object
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 prop-
erty, 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” .
var object = new Boolean(value);
var b1 = new Boolean(5);
var b2 = new Boolean(null);
<head><title>Boolean Object</title></head>
<body bgcolor=aqua>
<font face="arial" size="+1"><b>
The Boolean Object<br />
<script type="text/javascript">
var bool1= new Boolean( 0);
var bool2 = new Boolean(1);
var bool3 = new Boolean("");
var bool4 = new Boolean(null);
var bool5 = new Boolean(NaN);
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 " +
bool3 + "<br />");
document.write("The value of null is boolean " + bool4 +
"<br />");
Search WWH ::

Custom Search