Mega Code Archive

 
Categories / JavaScript Tutorial / Number Data Type
 

Number prototype

Syntax Number.prototype.property     Number.prototype.method The prototype property allows you to add properties or methods to all instances of this class. <html>     <body>     <script language="JavaScript">     <!--     var myProp = new Number();     function triple(num){         var result;         result = (num * 3);         return result;     }     Number.prototype.calc3 = triple;     document.write("Example demonstrates the prototype property for the number object."+ "<br><br>");     document.write("150 tripled is: " + myProp.calc3(150) + "<br>");     -->     </script>     </body>     </html>