20.3 Boolean Objects
20.3.1 The Boolean Constructor
The Boolean
- is %Boolean%.
- is the initial value of the
"Boolean" property of theglobal object . - creates and initializes a new Boolean object when called as a
constructor . - performs a type conversion when called as a function rather than as a
constructor . - may be used as the value of an
extends
clause of a class definition. Subclassconstructors that intend to inherit the specified Boolean behaviour must include asuper
call to the Booleanconstructor to create and initialize the subclass instance with a [[BooleanData]] internal slot.
20.3.1.1 Boolean ( value )
This function performs the following steps when called:
- Let b be
ToBoolean (value). - If NewTarget is
undefined , return b. - Let O be ?
OrdinaryCreateFromConstructor (NewTarget,"%Boolean.prototype%" , « [[BooleanData]] »). - Set O.[[BooleanData]] to b.
- Return O.
20.3.2 Properties of the Boolean Constructor
The Boolean
- has a [[Prototype]] internal slot whose value is
%Function.prototype% . - has the following properties:
20.3.2.1 Boolean.prototype
The initial value of Boolean.prototype
is the
This property has the attributes { [[Writable]]:
20.3.3 Properties of the Boolean Prototype Object
The Boolean prototype object:
- is %Boolean.prototype%.
- is an
ordinary object . - is itself a Boolean object; it has a [[BooleanData]] internal slot with the value
false . - has a [[Prototype]] internal slot whose value is
%Object.prototype% .
20.3.3.1 Boolean.prototype.constructor
The initial value of Boolean.prototype.constructor
is
20.3.3.2 Boolean.prototype.toString ( )
This method performs the following steps when called:
- Let b be ?
ThisBooleanValue (this value). - If b is
true , return"true" ; else return"false" .
20.3.3.3 Boolean.prototype.valueOf ( )
This method performs the following steps when called:
- Return ?
ThisBooleanValue (this value).
20.3.3.3.1 ThisBooleanValue ( value )
The abstract operation ThisBooleanValue takes argument value (an
- If value
is a Boolean , return value. - If value
is an Object and value has a [[BooleanData]] internal slot, then- Let b be value.[[BooleanData]].
Assert : bis a Boolean .- Return b.
- Throw a
TypeError exception.
20.3.4 Properties of Boolean Instances
Boolean instances are