JavaScript Number.prototype Property

JavaScript Number.prototype Property

The Number.prototype property allows you to add new properties and methods to JavaScript numbers.

Note: Prototype is a global property which is available with almost all JavaScript objects.

In the following example, we will create a new method called tenTimes(), which will multiply any given number by 10.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> Number.prototype.tenTimes = function() { return this.valueOf() * 10; }; var num = 5; document.write(num.tenTimes()); </script> </body> </html>

Syntax

Number.prototype.name = value

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Meet the Author