The type of
Infinity is a
When it happens users of your web app get to see 'Infinity'.
It can happen with mathematical functions like,
Math.pow(10, 309) // Exactly changes to infinity at 10^309 Math.log(0) // Infinity (1/0) // Infinity -(1/0) // -Infinity (1/Infinity) // 0 typeof Infinity === Number // true
To show users a more friendly "N/A", currently you can validate Infinity in the following ways.
Notice the difference in
Number.isFinite(). The later is more robust in checking for finite values.
But both of them fails to check just for
Infinity values reliably. This requires our custom
isInfinity() method added to your project. You can use it when you do some mathematical calculations.