Latest web development tutorials

JavaScript Boolean prototype constructor

Boolean Object Reference JavaScript Boolean objects

Examples

Create a new method for the Boolean object:

Boolean.prototype.myColor = function ()
{
if (this.valueOf () == true)
{
this.color = "green";
}
else
{
this.color = "red";
}
}

Create a Boolean object and add myColor methods:

var a = new Boolean (1);
a.myColor ();
var b = a.color;

b Results output:

green

try it"

Definition and Usage

prototype property gives you the ability to add properties and methods to an object.

When constructing a prototype, all Boolean objects are added to the default property or method.

Note: Boolean.prototype Boolean value that is not a reference, but the Boolean () Object Yes.

Note: Prototype is a global property, which for almost all of the JavaScript object.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support prototype property.


grammar

Boolean.prototype.name= value


Boolean Object Reference JavaScript Boolean objects