In JavaScript, the Number object provides several properties that can be useful for various operations involving numbers. Here are some commonly used properties of the Number object:
1. Number.MAX_VALUE:
- Description: Represents the maximum numeric value representable in JavaScript.
- Example:
console.log(Number.MAX_VALUE); // Output: 1.7976931348623157e+308
2. Number.MIN_VALUE:
- Description: Represents the smallest positive numeric value greater than zero.
- Example:
console.log(Number.MIN_VALUE); // Output: 5e-324
3. Number.POSITIVE_INFINITY:
- Description: Represents positive infinity.
- Example:
console.log(Number.POSITIVE_INFINITY); // Output: Infinity
4. Number.NEGATIVE_INFINITY:
- Description: Represents negative infinity.
- Example:
console.log(Number.NEGATIVE_INFINITY); // Output: -Infinity
5. Number.NaN:
- Description: Represents "Not-a-Number" (NaN) value.
- Example:
console.log(Number.NaN); // Output: NaN
6. Number.EPSILON:
- Description: Represents the difference between 1 and the smallest floating-point number greater than 1, approximately 2.220446049250313e-16.
- Example:
console.log(Number.EPSILON); // Output: 2.220446049250313e-16
7. Number.MAX_SAFE_INTEGER:
- Description: Represents the maximum safe integer in JavaScript (2^53 - 1).
- Example:
console.log(Number.MAX_SAFE_INTEGER); // Output: 9007199254740991
8. Number.MIN_SAFE_INTEGER:
- Description: Represents the minimum safe integer in JavaScript (-(2^53 - 1)).
- Example:
console.log(Number.MIN_SAFE_INTEGER); // Output: -9007199254740991
These properties provided by the Number object are helpful for performing various operations and comparisons involving numeric values in JavaScript.