Boolean.toSource() (Method)

Returns a Boolean object formatted as a Boolean literal contained in a string.

Availability:

JavaScript - 1.3
Netscape - 4.06
Opera - 3.0
Property/method value type:String primitive
JavaScript syntax:NmyBoolean.toSource()

This is an alternative way to retrieve a string version of a Boolean value. In this case, it is formatted as a Boolean literal and can then be used in an eval() function to assign another Boolean.

If you run the example below, it should yield this as a result:

(new Boolean(true))

However, you should note that this is not supported by MSIE browsers.

The result of calling this method is a string version of the Boolean formatted as a Boolean literal.

Example code:

   // Create a Boolean object and then examine its source

   myBoolean = new Boolean(true);

   document.write(myBoolean.toSource());

See also:Boolean.prototype, Boolean.toString()