JavaScript Boolean Class



Navigation Aids -- This Page        Navigation Aids -- This Topic        Navigation Aids -- This Site








Quick Reference for Boolean Class



The Boolean Class Reference Table
Native class
Inherits From Object
Constants Properties Methods Constructors
Syntax Arguments Returns
 
None None toString( )
valueOf( )
new Boolean( ) value A new boolean.




Boolean Class Description

The Boolean class is a wrapper class for the primitive boolean data type. Because the Boolean class will behave like any other class, the following behavior and characteristics apply:

The variables representing Boolean classes must be compared by reference as opposed to by value. You should use the identity operator.


Boolean Class Constants

There are no explicit constants for the class.





Boolean Class Properties

There are no explicit properties for the class.

The Boolean class does inherit the following properties from the base Object class.





Boolean Class Instance Methods

The Boolean class does inherit some methods from the base Object class.

The explicit methods of the Boolean class are shown below. Two of these methods (toLocaleString and valueOf) override the corresponding methods of the base Object class.



The Methods for the Boolean Class
Method Syntax / Arguments Returns Description / Example
 
toString( ) Syntax:
bobj.toString( )

Arguments: None
Returns a string of a Boolean class. The toString( ) method behaves as follows:
  • returns a string version of the Boolean class
  • the returned value will be either "true" or "false"
  • the method will throw a TypeError exception when the method is invoked on an object that is not a Boolean.

Example:
var boovar = new Boolean(1); // 1 as argument to constructor alert(boovar.toString()); // returns string "true"
valueOf( ) Syntax:
bobj.valueOf( )

Arguments: None
Returns a boolean value: true or false. The valueOf( ) method behaves as follows:
  • valueOf( ) returns the primitive boolean value contained in the Boolean class
  • the returned value will be either true or false
  • the method will throw a TypeError exception when the method is invoked on an object that is not a Boolean.
Example:
// boolean object with number as argument // boovar.valueOf() evaluates to true var boovar = new Boolean(1); alert(boovar.valueOf());




Boolean Class Constructor





Boolean Class Constructor Example



Top            

Rx4AJAX        About Us | Topic Index | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson