JavaScript

JavaScript is a high-level, interpreted programming language that is widely used for web development. Initially designed as a client-side scripting language, it runs directly in web browsers, enabling dynamic and interactive user experiences. JavaScript can now be used for server-side development as well.

JavaScript Number Properties

8 April 2025 | Category:

In JavaScript, the Number object comes with built-in properties that help us understand the limits and special values of numbers in JavaScript.

These properties are static, meaning they are accessed using Number.propertyName, not on number instances.


✅ 1. Number.MAX_VALUE

Returns the largest possible number in JavaScript.

console.log(Number.MAX_VALUE); 
// Output: 1.7976931348623157e+308

Any number larger than this is considered Infinity.


✅ 2. Number.MIN_VALUE

Returns the smallest positive number (closest to 0, not negative).

console.log(Number.MIN_VALUE);
// Output: 5e-324

It is not the most negative number — it’s the smallest you can go before getting 0.


✅ 3. Number.POSITIVE_INFINITY

Represents positive infinity.

console.log(Number.POSITIVE_INFINITY); // Infinity
console.log(1 / 0);                    // Infinity

✅ 4. Number.NEGATIVE_INFINITY

Represents negative infinity.

console.log(Number.NEGATIVE_INFINITY); // -Infinity
console.log(-1 / 0);                   // -Infinity

✅ 5. Number.NaN

Represents the special value “Not-a-Number”.

console.log(Number.NaN);         // NaN
console.log("abc" * 3);          // NaN
console.log(isNaN("abc" * 3));   // true

Note: You can also use the global NaN keyword. Number.NaN === NaN is true.


✅ 6. Number.MAX_SAFE_INTEGER

The largest integer you can safely represent in JavaScript without losing precision.

console.log(Number.MAX_SAFE_INTEGER); 
// Output: 9007199254740991

Beyond this, integers may lose accuracy. Use BigInt for very large numbers.


✅ 7. Number.MIN_SAFE_INTEGER

The smallest safe integer in JavaScript.

console.log(Number.MIN_SAFE_INTEGER); 
// Output: -9007199254740991

📌 All Number Properties – Summary Table

Property NameDescriptionExample Output
Number.MAX_VALUELargest possible number1.7976931348623157e+308
Number.MIN_VALUESmallest positive number5e-324
Number.POSITIVE_INFINITYRepresents positive infinityInfinity
Number.NEGATIVE_INFINITYRepresents negative infinity-Infinity
Number.NaNNot a NumberNaN
Number.MAX_SAFE_INTEGERLargest safe integer (for precision)9007199254740991
Number.MIN_SAFE_INTEGERSmallest safe integer-9007199254740991

🧠 Important Notes

  • These properties are read-only.
  • They are accessed through the Number object, not from number instances.
  • For extremely large or small numbers, JavaScript may return Infinity or 0.