Mega Code Archive

 
Categories / JavaScript Tutorial / Number Data Type
 

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>