Create a method that gives the number object a property that returns the number's half value:
Make a Number object, then call the myMet method:
var x = n.myProp;
The result of x will be:
Try it yourself »
Definition and Usage
The prototype constructor allows you to add new properties and methods to the Number() object.
When constructing a property, ALL number objects will be given the property, and its value, as default.
When constructing a method, ALL number objects will have this method available.
Note: Number.prototype does not refer to a single number object, but to the Number() object itself.
The prototype property is supported in all major browsers.
Thank You For Helping Us!
Your message has been sent to W3Schools.