English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
prototypeLe proprietà possono aggiungere proprietà e metodi al tuo oggetto Number.
Attenzione:La proprietà prototype è una proprietà globale disponibile praticamente per tutti gli oggetti (numeri, array, stringhe, date, ecc.).
Number.prototype.name = value
Crea un nuovo metodo numerico che restituisce il valore doppiato del numero:
Number.prototype.getTwice = function() { return (this.valueOf() * 2); };
Usa i nuovi metodi per i numeri:
var a = 25; var b = a.getTwice(); // Chiamata al nuovo metodo
Tutti i browser supportano completamente la proprietà prototype:
Proprietà | |||||
prototype | Sì | Sì | Sì | Sì | Sì |