Boolean.prototype (Property)

The prototype for the Boolean object that can be used to extend the interface for all Boolean objects.

Availability:

ECMAScript edition - 2
JavaScript - 1.1
JScript - 3.0
Internet Explorer - 4.0
Netscape - 3.0
Netscape Enterprise Server - 2.0
Opera - 3.0
Property/method value type:Boolean object
JavaScript syntax:-Boolean.prototype
-myBoolean.constructor.prototype

The initial value of the prototype of a Boolean object is the built-in Boolean prototype object.

The example demonstrates how to provide extensions to all instances of this class by adding a function to the prototype object.

Example code:

   <HTML>
   <HEAD>
   </HEAD>
   <BODY>
   <SCRIPT>
   // Define a function that extends the output capabilities of Boolean objects
   function yesNo()
   {
      if(this == true)
      {
         return "The switch is ON"; 
      }
      else
      {
         return "The switch is OFF";
      }
   }
   // Register the new function
   Boolean.prototype.yesNo = yesNo;
   // Create a Boolean object and test the Boolean.yesNo() method
   myBoolean = new Boolean(true);
   document.write(myBoolean.yesNo());
   document.write("<BR>");
   myBoolean = !myBoolean;
   document.write(myBoolean.yesNo());
   document.write("<BR>");
   </SCRIPT>
   </BODY>
   </HTML>

See also:Boolean object, Boolean.constructor, Boolean.toSource(), Boolean.toString(), Boolean.valueOf(), prototype property

Cross-references:

ECMA 262 edition 2 - section - 15.2.3.1

ECMA 262 edition 2 - section - 15.6.3.1

ECMA 262 edition 3 - section - 15.6.3.1