Easy Tutorial
❮ Jsref Getutcminutes Prop Style Wordbreak ❯

JavaScript Number prototype Property

JavaScript Number Object

Example

Create a method that provides the property of a number object and returns half of its value:

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

Create a Number object and call the myMet method:

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

x Output result:


Definition and Usage

The prototype property allows you to add properties and methods to objects.

When constructing a property, all Number objects will be given this property and its value.

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

Note: Number.prototype does not refer to a single Number object but can be used with the Number() object.

Note: prototype is a type of global object constructor that can be used for all JavaScript objects.


Browser Support

All major browsers support the prototype property.


Syntax


JavaScript Number Object

❮ Jsref Getutcminutes Prop Style Wordbreak ❯