JavaScript: Boolean Object
Boolean
is the value of the property key "Boolean"
of the Global Object
.
console.log( window.Boolean === Boolean );
Type
Type of Boolean
is a function.
console.log( typeof Boolean === "function" );
Parent
Parent of Boolean
is Function.prototype.
console.log( Reflect.getPrototypeOf ( Boolean ) === Function.prototype );
Purpose
Purpose of Boolean
is:
- Implicitly called by JavaScript to convert value to
true
orfalse
. e.g. in aif
statement. - Implicitly called by JavaScript to convert
true
orfalse
to string, by first converting the value to boolean object, then use methodtoString
. - Has the property key
"prototype"
that holdsvalueOf
andtoString
methods.
[see true, false]