prototype (Number - JavaScript)

Extends the object with additional properties and methods.

Defined in

Number (Standard - JavaScript)

Syntax

prototype.name = value
Return value Description
name The name of the property or method.
value The value of the property or method. For a property, this should be an expression. For a method, this should be a function definition.

Examples

(1) This computed label defines a property for the Number object then uses it.
Number.prototype.tomiles = 0.6214;

var n = new Number(90);
n * n.tomiles
(2) This computed label defines a function for the Number object then calls it.
Number.prototype.volume = function() {
	return this * this * this;
}
var n = new Number(5);
n.volume() // 125.0