Number properties are predefined values available inside the Number object.
They give you information about:
-
Maximum and minimum possible numbers
-
Safe integer limits
-
Special values like infinity
-
Floating-point precision
These properties are accessed using:
1. Number.MAX_VALUE
Number.MAX_VALUE returns the largest possible number JavaScript can handle.
Example output:
1.7976931348623157e+308
Why it matters:
If a number becomes larger than this, JavaScript returns Infinity.
2. Number.MIN_VALUE
Number.MIN_VALUE returns the smallest positive number greater than zero.
Output:
5e-324
This is useful in scientific and high-precision calculations.
3. Number.POSITIVE_INFINITY
Represents infinity when a value becomes too large.
Output:
Infinity Infinity
4. Number.NEGATIVE_INFINITY
Represents negative infinity.
Output:
-Infinity -Infinity
5. Number.NaN
NaN means Not a Number.
It represents an invalid numeric result.
Output:
NaN NaN
This is very useful for validating calculations.
6. Number.MAX_SAFE_INTEGER
Returns the largest integer JavaScript can safely represent.
Output:
9007199254740991
Numbers larger than this can cause accuracy issues.
7. Number.MIN_SAFE_INTEGER
Returns the smallest safe integer.
Output:
-9007199254740991
Real-World Example: Preventing Calculation Errors
Output:
9007199254741001 false
This shows why understanding number properties in JavaScript is important for reliable applications such as:
-
Banking systems
-
Finance apps
-
Analytics dashboards
-
Scientific calculations
Summary of Important Number Properties
| Property | Meaning |
|---|---|
| Number.MAX_VALUE | Largest possible number |
| Number.MIN_VALUE | Smallest positive number |
| Number.POSITIVE_INFINITY | Represents infinity |
| Number.NEGATIVE_INFINITY | Represents negative infinity |
| Number.NaN | Not a valid number |
| Number.MAX_SAFE_INTEGER | Largest safe integer |
| Number.MIN_SAFE_INTEGER | Smallest safe integer |
Common Mistakes Beginners Make
Ignoring safe integer limits
Correct awareness
Use Number.MAX_SAFE_INTEGER to validate large values before calculations.
Why Number Properties Are Important in JavaScript
Learning JavaScript number properties helps you:
-
Avoid precision errors
-
Handle edge cases safely
-
Build reliable applications
-
Improve interview performance
-
Strengthen JavaScript fundamentals
These concepts are often asked in JavaScript technical interviews.