Is NaN always a falsy value in Javascript?

405 Views Asked by At

console.log(typeof 3/0, Boolean(3/0)); // This returns NaN true
console.log(typeof 0/0, Boolean(0/0)); // This returns NaN false

I thought both will return NaN false in the Console as NaN is falsy value. But this is not happening. Can someone please explain this.

I used VS Code editor and Google Chrome Browser.

1

There are 1 best solutions below

0
Julien On

The result of 3/0 is Infinity (which is not NaN).

Infinity is a thruty value by spec.