The Number.isNaN function returns true if and only if the value equals NaN. Otherwise, in every other case, it returns false. That means it will not try to typecast something which is not a number, to a number (which usually results in NaN being returned).
Check the following example:
let a = "NaN";let b = NaN;let c = "hello";let d = 12;console.log(Number.isNaN(a)); // falseconsole.log(Number.isNaN(b)); // trueconsole.log(Number.isNaN(c)); // falseconsole.log(Number.isNaN(d)); // false
Here you can see that the Number.isNaN() method returns true only if the passed value is exactly NaN. You might ask, why not use == or the === operator instead of the Number.isNaN(value) method? The NaN value is the only value ...