BooleanNN 3 IE 4 ECMA 1  

  

A Boolean object represents any value that evaluates to true or false. By and large, you don't have to worry about the Boolean object because the browsers automatically create such objects for you when you assign a true or false value to a variable. Quoted versions of these values are treated only as string.

 
Properties
 
constructor prototype
 
Methods
 
toString( ) valueOf( )
 
Creating a Boolean Object
 
var myValue = new Boolean( );
var myValue = new Boolean(BooleanValue);
var myValue = BooleanValue;
constructorNN 4 IE 4 ECMA 1  

Read/Write  

This is a reference to the function that created the instance of a Boolean objectthe native Boolean( ) constructor function in browsers.

 
Example
 
if (myVar.constructor == Boolean) {
    // process native string
}
 
Value

Function object reference.

prototypeNN 3 IE 4 ECMA 1  

Read/Write  

This is a property of the static Boolean object. Use the prototype property to assign new properties and methods to future instances of a Boolean value created in the current document. See the Array.prototype property description for examples. There is little need to create new prototype properties or methods for the Boolean object.

 
Example
 
Boolean.prototype.author = "DG";
 
Value

Any data, including function references.

toString( )NN 4 IE 4 ECMA 1  

  

Returns the object's value as a string data type. You don't need this method in practice, because the browsers automatically convert Boolean values to strings when they are needed for display in alert dialogs or in-document rendering.

 
Parameters

None.

 
Returned Value

"true" | "false"

valueOf( )NN 4 IE 4 ECMA 1  

  

Returns the object's value as a Boolean data type. You don't need this method when you create Boolean objects by simple value assignment.

 
Parameters

None.

 
Returned Value

Boolean value: true | false.