Tutorials
JavaScriptProperties are the values associated with an object. A Boolean object has only one property, the value of the object - which is either true or false.
Two methods used with Boolean Objects are:
valueOf()
toString()
valueOf() is used to return the primitive value of a Boolean object.
|
For example:
|
In the above example, a boolean object exforsys is created with its initial value set as true. The value of the boolean object exforsys is printed using the valueOf() with the boolean object exforsys resulting in a true value.
The toString() method is used to convert a Boolean value to a string and returns the result.
|
For example:
|
The output of the above example is
|
In the above example, a boolean object exforsys is created with its initial value set as true. Then this Boolean value true is converted to a string using the method toString() along with the boolean object exforsys. This is outputs, resulting in a true string.
First Page: JavaScript Boolean Object