‟Ex igne vita”
When
Boolean
is called
as a function rather than as a constructor, it performs a type
conversion.
Returns a Boolean value (not a Boolean object) computed by ToBoolean(value).
When
Boolean
is called
as part of a new
expression it is a constructor: it initialises the newly created
object.
The
[[Prototype]] internal property of the newly constructed object is
set to the original Boolean prototype object, the one that is the
initial value of Boolean.prototype
(15.6.3.1).
The
[[Class]] internal property of the newly constructed Boolean object
is set to "Boolean"
.
The [[PrimitiveValue]] internal property of the newly constructed Boolean object is set to ToBoolean(value).
The [[Extensible]] internal property of the newly constructed object is set to true.
The value of the [[Prototype]] internal property of the Boolean constructor is the Function prototype object (15.3.4).
Besides
the internal properties and the length
property (whose value is 1), the Boolean constructor has the
following property:
The
initial value of Boolean.prototype
is the Boolean prototype object (15.6.4).
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
The
Boolean prototype object is itself a Boolean object (its [[Class]]
is "Boolean"
)
whose value is false.
The value of the [[Prototype]] internal property of the Boolean prototype object is the standard built-in Object prototype object (15.2.4).
The
initial value of Boolean.prototype.constructor
is the built-in Boolean
constructor.
The following steps are taken:
Let B be the this value.
If Type(B) is Boolean, then let b be B.
Else
if Type(B) is Object and the value of the [[Class]] internal
property of B is "Boolean"
,
then let b be the value of the [[PrimitiveValue]] internal
property of B.
Else throw a TypeError exception.
If
b is true, then return "true"
;
else return "false"
.
The following steps are taken:
Let B be the this value.
If Type(B) is Boolean, then let b be B.
Else
if Type(B) is Object and the value of the [[Class]] internal
property of B is "Boolean"
,
then let b be the value of the [[PrimitiveValue]] internal
property of B.
Else throw a TypeError exception.
Return b.
Boolean
instances inherit properties from the Boolean prototype object and
their [[Class]] internal property value is "Boolean"
.
Boolean instances also have a [[PrimitiveValue]] internal property.
The [[PrimitiveValue]] internal property is the Boolean value represented by this Boolean object.