Javascript

Javascript Number isNaN() method

This article is all about the Javascript Number isNaN() method and its applications.

Javascript isNaN() method of Number Object

According to the MDN Docs “The Number.isNaN() method determines whether the passed value is NaN and its type is Number. It is a more robust version of the original, global isNaN()”.

Also Read: Async Await in Javascript.

This means a number is NaN only if it’s NaN or if it’s a division of 0 by 0 expression, which returns NaN. In all the other cases, we can pass it what we want but it will return false:

Javascript isNaN() method Examples

Number.isNaN(NaN);        // true
Number.isNaN(Number.NaN); // true
Number.isNaN(0 / 0);      // true
Number.isNaN('NaN');      // false
Number.isNaN(undefined);  // false
Number.isNaN({});         // false
Number.isNaN('blabla');   // false

So, this is all about the Javascript isNaN method. Thanks for Reading!

Leave a Comment