JavaScript Number Properties
8 April 2025 | Category: JavaScript
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 Name | Description | Example Output |
---|---|---|
Number.MAX_VALUE | Largest possible number | 1.7976931348623157e+308 |
Number.MIN_VALUE | Smallest positive number | 5e-324 |
Number.POSITIVE_INFINITY | Represents positive infinity | Infinity |
Number.NEGATIVE_INFINITY | Represents negative infinity | -Infinity |
Number.NaN | Not a Number | NaN |
Number.MAX_SAFE_INTEGER | Largest safe integer (for precision) | 9007199254740991 |
Number.MIN_SAFE_INTEGER | Smallest 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
or0
.