Boolean.prototype : Boolean « Number Data Type « JavaScript Tutorial






Syntax

Boolean.prototype.property
    Boolean.prototype.method

The prototype property allows you to add new properties and methods to the Boolean object that can be used throughout your code.

The following example assigns a New Method to the Boolean Object with the prototype Property.

<html>
    <script language="JavaScript">
    <!--
    function letterBoolean() {
      if(this == true)
        return("T");
      else
        return("F");
    }
    //Make the letterBoolean function available to all Boolean objects
    Boolean.prototype.letter = letterBoolean;

    var myBooleanObj = new Boolean(true);

    document.write("myBooleanObj is set to ",myBooleanObj.letter());  
    -->
    </script>
    </html>








5.2.Boolean
5.2.1.Boolean
5.2.2.Boolean Object Verses Primitive Boolean Value
5.2.3.Boolean.prototype
5.2.4.Boolean.toSource()
5.2.5.Boolean.toString()
5.2.6.Boolean.valueOf()