SoFunction
Updated on 2025-04-03

Properties parsing of Boolean objects in JavaScript

constructor properties

Example
Returns a function created through the prototype of the myvar object:

var myvar = new Boolean(1);
;


Results output:

function Boolean() { [native code] }

Definition and usage
The constructor property returns a reference to the Boolean function that created this object.


prototype constructor
Create a new method for the Boolean object:

=function()
{
if (()==true)
 {
 ="green";
 }
else
 {
 ="red";
 }
}

Create a Boolean object and add the myColor method:

var a=new Boolean(1);
();
var b=;


b Results output:

green

Definition and usage
The prototype attribute gives you the ability to add properties and methods to objects.
When constructing a prototype, all Boolean objects have properties or methods added by default.
Note: Prototype is a global property, which is for almost all JavaScript objects.