What is negative Infinity?

561
february 22, 2023, at 23:22

In JavaScript, Infinity and -Infinity are special values that represent positive infinity and negative infinity, respectively. These values are used to represent numbers that are too large (or too small) to be represented as regular numbers.

Negative infinity (-Infinity) is a value that is less than any other number, including negative numbers. It is the result of dividing a negative number by zero, or subtracting Infinity from a negative number. For example:

Negative infinity can also be compared to other numbers using the usual comparison operators (<, >, <=, >=). For example:

Note that the special values Infinity and -Infinity are not actually numbers, but are rather of the type number. They can be used in mathematical operations like regular numbers, but they have some special properties and behaviors, such as being immutable and not being equal to any other value, including themselves (i.e., Infinity !== Infinity and -Infinity !== -Infinity).