If you can use ECMAScript 6 , you Object.is:
return Object.is(obj, NaN);
Otherwise, this is one of the options from underscore.js source code :
_.isNaN = function(obj) {
return obj !== obj;
};
Also their note for this function:
Note: this is not the same as the nativeNaN function, which will also return true if the variable is undefined.
source
share