Number.prototype (Property)

The prototype for the Number object that can be used to extend the interface for all Number objects.

Availability:

ECMAScript edition - 2
JavaScript - 1.1
JScript - 1.0
Internet Explorer - 3.02
Netscape - 3.0
Netscape Enterprise Server version - 2.0
Opera - 3.0
Property/method value type:Number object
JavaScript syntax:-Number.prototype
-myNumber.constructor.prototype

The prototype property refers to the built-in Number prototype object.

The example demonstrates how to provide extensions to all instances of this class by adding a function to the prototype object.

Example code:

   <HTML>
   <HEAD>
   </HEAD>
   <BODY>
   <SCRIPT>
   // Define a function that extends the capabilities of the Number object
   function pythag(aValue1, aValue2)
   {
   return Math.sqrt((aValue1*aValue1) + (aValue2*aValue2));
   }
   // Register the new function
   Number.prototype.pythag = pythag;
   myNumber = new Number();
   // Create a number object and test the Number.pythag() method
   document.write(myNumber.pythag(3, 4))
   document.write("<BR>")
   </SCRIPT>
   </BODY>
   </HTML>

See also:Number object, Number(), Number(), Number.constructor, Number.toString(), Number.valueOf(), prototype property

Property attributes:

DontDelete, DontEnum.

Cross-references:

ECMA 262 edition 2 - section - 15.2.3.1

ECMA 262 edition 2 - section - 15.7.4

ECMA 262 edition 3 - section - 15.7.3.1