The prototype constructor can add new properties and methods to JavaScript Number class.
The prototype constructor can add new properties and methods to JavaScript Number class.
Number.prototype.name = value
The following code shows how to create a new number method that returns a number's half value:
Number.prototype.myMethod = function() { return this.valueOf() / 2; }; var n = 55;//from w w w .ja v a2 s. c o m console.log(n.myMethod());