Boolean object (Object/core)

An object of the class "Boolean".


ECMAScript edition - 2
JavaScript - 1.1
JScript - 3.0
Internet Explorer - 4.0
Netscape - 3.0
Netscape Enterprise Server - 2.0
Opera - 3.0
JavaScript syntax:-myBoolean = BooleanValue
-myBoolean = new Boolean()
-myBoolean = new Boolean(aValue)
Argument ListBooleanValueA Boolean value (either true or false)
aValueA value to be converted to a Boolean object.
Object properties:constructor, prototype
Object methods:toSource(), toString(), valueOf()

An instance of the class "Boolean" is created by using the new operator on the Boolean() constructor. The new object adopts the behavior of the built-in Boolean prototype object through the prototype-inheritance mechanisms.

All properties and methods of the prototype are available as if they were part of the new instance.

A Boolean object is a member of the type object and is an instance of the built-in Boolean object.

Cloning the built-in Boolean object creates Boolean objects is done by calling the Boolean() constructor with the new operator. For example:

myBoolean = new Boolean(true);

A Boolean object can be coerced into a Boolean value and can be used anywhere that a Boolean value would be expected.

Programmers familiar with object-oriented techniques may be happy to use the Boolean object, while procedural language programmers may prefer to implement the same functionality with a Boolean value instead.

This is an example of the flexibility of JavaScript in its ability to accommodate a variety of users from different backgrounds.

The prototype for the Boolean prototype object is the Object prototype object.

See also:Boolean.prototype, Native object, Object object, unwatch(), watch()

constructor1.1 1.13.0 3.03.0 3.04.0 4.0 n/a n/a2 2 n/a n/a n/a-
prototype1.1 1.13.0 3.03.0 3.04.0 4.03.0 3.02.0 2.02 2 n/a n/a n/a-

toSource()1.3 1.3 n/a4.06 4.06 n/a3.0 3.0 n/a n/a n/a n/a n/a-
toString()1.1 1.13.0 3.03.0 3.04.0 4.03.0 3.02.0 2.02 2 n/a n/a n/a-
valueOf()1.1 1.13.0 3.03.0 3.04.0 4.0 n/a n/a2 2 n/a n/a n/a-


ECMA 262 edition 2 - section - 4.3.15

ECMA 262 edition 2 - section - 10.1.5

ECMA 262 edition 2 - section - 15.6

ECMA 262 edition 3 - section - 4.3.15

ECMA 262 edition 3 - section - 15.6