English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript Number prototype Property

 JavaScript Number Object

prototypeProperties can add properties and methods to your Number object.

Note:Prototype is a global property that is available for almost all objects (numbers, arrays, strings, and dates, etc.).

Syntax:

Number.prototype.name = value

Create a new number method that returns the double precision value of the number:

Number.prototype.getTwice = function() {
return (this.valueOf() * 2);
};

Use the new method for numbers:

var a = 25;
var b = a.getTwice();// Invoke a new method

Test and see‹/›

Browser Compatibility

All browsers fully support the prototype property:

Properties
prototypeYesYesYesYesYes

 JavaScript Number Object