Design & Download
Your JS Library
in Seconds!!!

Snippet: isNaN() ES6 Style

Written by Christopher West (cwest) on November 29, 2015.
Determines if what is passed in is literally NaN.
function isNaN(value) {
  return typeOf(value, 'Number') && __global.isNaN(value);
}

At times you may want to check if something is actually NaN and not just a value that is "not a number". In that case you will want to use this snippet because using the global isNaN() function for this purpose can give you false positives:

isNaN({});  // true
isNaN(NaN); // true

YourJS.isNaN({});  // false
YourJS.isNaN(NaN); // true

isNaN() API Documentation

Description

Determines if what is passed in is literally NaN.

Parameters

  1. value {*}:
    The value to be tested to see if it is literally NaN.

Returns

Returns true if value is NaN, otherwise false is returned.