JavaScript Number.prototype

Beginner
5 min read
Updated: Nov 2026
3 examples

Definition

Number.prototype holds methods shared by numbers, such as toFixed() and toString(). Number values use these methods through the prototype chain.

Syntax

JavaScript
typeof Number.prototype.toFixed;
(3.14159).toFixed(2);

Parameters

NameDescription
—Property on the Number constructor.

Return value

The prototype object for Number instances.

Examples

Example 1 — Call a prototype method

Parentheses help when the number is a literal.

JavaScript
console.log((2.5).toFixed(0));
console.log((255).toString(16));
Try it

Example 2 — Shared function

All numbers share toFixed.

JavaScript
console.log((1).toFixed === (2).toFixed);
Try it

Example 3 — Prefer Number.isNaN for checks

Static helpers live on Number, not the prototype.

JavaScript
console.log(Number.isNaN(NaN));
Try it

Frequently Asked Questions

The object that stores shared number methods.
A bare 2.5.toFixed can be parsed as a decimal. Parentheses make the method call clear.

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful