value === !Infinity
actually makes a falsy value
Instead, use !==
(strict equality operator) when checking for a finite number.
1 min readJul 31, 2020
Hey Алексей, Thanks for reading and responding!
Using the !
operator (the NOT operator) actually invokes truthy and falsy rules in JavaScript. Since Infinity
is truthy, then !Infinity
will always have a value of false
. And your number value would never equal false:
console.log(!Infinity) // false
console.log(3 === !Infinity) // falseconsole.log(3 !== Infinity) // true
Instead, you want to use !==
(the strict equality operator).