Latest web development tutorials

JavaScript Number prototype property

Date Object Reference JavaScript Number Object

Examples

Create a method, given the properties of digital objects, return the value of half the numbers:

Number.prototype.myMet=function()
{
this.myProp=this.valueOf()/2;
}

Create a Number object, call myMet method:

var n = new Number(55);
n.myMet();
var x = n.myProp;

x output:

27.5

try it"

Definition and Usage

Run your prototype property to add properties and methods to an object.

When constructing an attribute, all Number objects will be added on the attribute and value.

When constructing a method, all Number objects will have this method.

Note: Number.prototype not allowed to reference a single Number object, but you can use the Number () object.

Note: prototype model is the constructor of a global object, it is available for all JavaScript objects


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support prototype property


grammar

object.prototype. name = value


Date Object Reference JavaScript Number Object