The Number Data Type
Finite values are regular numbers that can be positive, negative, or zero. On the other hand, infinite values represent numbers that are beyond any finite number.
The Infinity Property
We can assign the Infinity value to a variable like this:
x = Infinity;
We can also perform arithmetic operations with Infinity. For example:
y = 10 / 0; // y will be Infinity
isFinite(Infinity); // returns false
Alternatively, you can use the isNaN() function to check if a value is NaN (Not a Number), which includes both Infinity and certain other special numeric values.
Note: It’s important to handle infinite values carefully in your code to avoid unexpected behaviors and errors.