JavaScript Number Properties
In JavaScript, the Number object provides several properties that represent various numeric values and constants.
Here are some commonly used Number properties:
- Number.MAX_VALUE
- Number.MIN_VALUE
- Number.NaN
- Number.NEGATIVE_INFINITY
- Number.POSITIVE_INFINITY
- Number.EPSILON
- Number.MAX_SAFE_INTEGER
- Number.MIN_SAFE_INTEGER
Number.MAX_VALUE
Represents the maximum numeric value that can be represented in JavaScript.
Example
console.log(Number.MAX_VALUE); // Output: 1.7976931348623157e+308
Number.MIN_VALUE
Represents the smallest positive numeric value greater than zero that can be represented in JavaScript.
Example
console.log(Number.MIN_VALUE); // Output: 5e-324
Number.NaN:
Represents the "Not-a-Number" value.
Example
console.log(Number.NaN); // Output: NaN
Number.NEGATIVE_INFINITY
Represents negative infinity.
Example
console.log(Number.NEGATIVE_INFINITY); // Output: -Infinity
Number.POSITIVE_INFINITY
Represents positive infinity.
Example
console.log(Number.POSITIVE_INFINITY); // Output: Infinity
Number.EPSILON
Represents the difference between 1 and the smallest floating-point number greater than 1, which is approximately 2.220446049250313e-16.
Example
console.log(Number.EPSILON); // Output: 2.220446049250313e-16
Number.MAX_SAFE_INTEGER
Represents the maximum safe integer in JavaScript, which is 2^53 - 1.
Example
console.log(Number.MAX_SAFE_INTEGER); // Output: 9007199254740991
Number.MIN_SAFE_INTEGER
Represents the minimum safe integer in JavaScript, which is -(2^53 - 1).