JS: Boolean.prototype

By Xah Lee. Date: . Last updated: .

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

[see JS: Boolean Object]

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

Type

Type of Boolean.prototype is object.

[see JS: Value Types]

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

[see JS: Prototype and Inheritance]

Purpose

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

Properties

  1. Boolean.prototype.constructor
  2. Boolean.prototype.valueOf
  3. Boolean.prototype.toString

Boolean.prototype.constructor

Value is Boolean.

console.log ( Boolean.prototype.constructor === Boolean ); // true

Boolean.prototype.valueOf

Boolean.prototype.toString () → converts the this binding to true or false.

console.log ( true.valueOf () === true ); // true
console.log ( false.valueOf () === false ); // true

Boolean.prototype.toString

Boolean.prototype.toString () → converts the this value to "true" or "false".

[see JS: “this” Binding]

console.log ( true.toString () === "true" ); // true
console.log ( false.toString () === "false" ); // true

JS Boolean

  1. true, false

Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. CSS
  3. JavaScript
  4. JS Obj Ref
  5. DOM
  6. SVG
  7. Blog