JavaScript : Number Properties

In JavaScript, the Number object provides several properties that represent numeric values or special numeric values. These properties are accessed directly on the Number object itself. Here are some commonly used number properties in JavaScript:

1. Number.MAX_VALUE


Represents the maximum representable numeric value in JavaScript.


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

2. Number.MIN_VALUE


Represents the smallest positive numeric value greater than zero.


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

3. Number.NaN


Represents a special value that indicates Not-a-Number (NaN).


console.log(Number.NaN);   // Output: NaN
 

4. Number.POSITIVE_INFINITY


Represents positive infinity.


console.log(Number.POSITIVE_INFINITY);   // Output: Infinity
 

5. Number.NEGATIVE_INFINITY


Represents negative infinity.


console.log(Number.NEGATIVE_INFINITY);   // Output: -Infinity
 

6. Number.EPSILON


Represents the difference between 1 and the smallest representable greater than 1.


console.log(Number.EPSILON);   // Output: 2.220446049250313e-16
 

7. Number.MAX_SAFE_INTEGER


Represents the maximum safe integer in JavaScript, which is 2^53 - 1.


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

8. Number.MIN_SAFE_INTEGER


Represents the minimum safe integer in JavaScript, which is -(2^53 - 1).


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

These properties are useful for various numerical operations and for checking the range and limits of numeric values in JavaScript.