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






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>








5.18.prototype
5.18.1.Number.prototype