JS: Boolean.prototype

By Xah Lee. Date: . Last updated: .

What is Boolean.prototype

Boolean.prototype is the value of the property key "prototype" of the function Boolean. 〔see Boolean Object

Boolean.hasOwnProperty("prototype");

Type

Type of Boolean.prototype is Object .

typeof Boolean.prototype === "object";

Boolean.prototype is a boolean object.

Reflect.apply(Object.prototype.toString, Boolean.prototype, []) ===
  "[object Boolean]";
Reflect.apply(Boolean.prototype.valueOf, Boolean.prototype, []) === false;

Parent

Parent of Boolean.prototype is Object.prototype .

Reflect.getPrototypeOf(Boolean.prototype) === Object.prototype;

Purpose

Purpose of Boolean.prototype is to hold methods valueOf and toString for converting values to true or false, or a string form.

Properties

Boolean.prototype.constructor

Value is Boolean.

Boolean.prototype.constructor === Boolean;
true.constructor === Boolean;
Boolean.prototype.valueOf()

Convert boolean object to primitive boolean.

console.log((new Boolean(true)).valueOf() === true);

console.log((new Boolean(false)).valueOf() === false);
Boolean.prototype.toString()

Convert boolean to string "true" or "false".

true.toString() === "true";
false.toString() === "false";

JavaScript. Boolean