20.3 Boolean Objects

20.3.1 The Boolean Constructor

The Boolean constructor:

  • is %Boolean%.
  • is the initial value of the "Boolean" property of the global 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. Subclass constructors that intend to inherit the specified Boolean behaviour must include a super call to the Boolean constructor to create and initialize the subclass instance with a [[BooleanData]] internal slot. Boolean ( value )

When Boolean is called with argument value, the following steps are taken:

  1. Let b be ! ToBoolean(value).
  2. If NewTarget is undefined, return b.
  3. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Boolean.prototype%", « [[BooleanData]] »).
  4. Set O.[[BooleanData]] to b.
  5. Return O.

20.3.2 Properties of the Boolean Constructor

The Boolean constructor:

  • has a [[Prototype]] internal slot whose value is %Function.prototype%.
  • has the following properties: Boolean.prototype

The initial value of Boolean.prototype is the Boolean prototype object.

This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.

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%.

The abstract operation thisBooleanValue takes argument value. It performs the following steps when called:

  1. If Type(value) is Boolean, return value.
  2. If Type(value) is Object and value has a [[BooleanData]] internal slot, then
    1. Let b be value.[[BooleanData]].
    2. Assert: Type(b) is Boolean.
    3. Return b.
  3. Throw a TypeError exception. Boolean.prototype.constructor

The initial value of Boolean.prototype.constructor is %Boolean%. Boolean.prototype.toString ( )

The following steps are taken:

  1. Let b be ? thisBooleanValue(this value).
  2. If b is true, return "true"; else return "false". Boolean.prototype.valueOf ( )

The following steps are taken:

  1. Return ? thisBooleanValue(this value).

20.3.4 Properties of Boolean Instances

Boolean instances are ordinary objects that inherit properties from the Boolean prototype object. Boolean instances have a [[BooleanData]] internal slot. The [[BooleanData]] internal slot is the Boolean value represented by this Boolean object.