English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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.).
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
All browsers fully support the prototype property:
Properties | |||||
prototype | Yes | Yes | Yes | Yes | Yes |