JavaScript: Boolean.prototype

By Xah Lee. Date: . Last updated: .

Boolean.prototype is the value of the property key "prototype" of the function Boolean.

[see Boolean Object]

console.log( Boolean.hasOwnProperty ( "prototype" ) ); // true

Type

Type of Boolean.prototype is Object .

console.log( typeof Boolean.prototype === "object" ); // true

Boolean.prototype is a boolean object.

console.log( 
Reflect.apply ( Object.prototype.toString , Boolean.prototype , [] ) === "[object Boolean]"
); // true

console.log( 
Object.prototype.valueOf.call ( Boolean.prototype )
); // [Boolean: false]

console.log( 
Reflect.apply ( Boolean.prototype.valueOf ,  Boolean.prototype , [] ) === false
); // true

Parent

Parent of Boolean.prototype is Object.prototype .

console.log( Reflect.getPrototypeOf ( Boolean.prototype ) === Object.prototype ); // true

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.
console.log( Boolean.prototype.constructor === Boolean ); // true
console.log( true.constructor === Boolean ); // true
val.valueOf()
Convert val to true or false.
console.log( true.valueOf () === true ); // true
console.log( false.valueOf () === false ); // true
val.toString()
Convert val to "true" or "false".
console.log( true.toString () === "true" ); // true
console.log( false.toString () === "false" ); // true
JS in Depth
XAH  BUY NOW

JS in Depth

JS Obj Ref

DOM


JS Obj Ref

Boolean

prototype