Boolean.prototype : Boolean : Number Data Type JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Number Data Type » Boolean »

 

Boolean.prototype










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>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Number Data Type
» Boolean