isNaN.js 453 B

12345678910111213141516
  1. var isNumber = require('./isNumber');
  2. var $isNaN = require('../number/isNaN');
  3. /**
  4. * Check if value is NaN for realz
  5. */
  6. function isNaN(val){
  7. // based on the fact that NaN !== NaN
  8. // need to check if it's a number to avoid conflicts with host objects
  9. // also need to coerce ToNumber to avoid edge case `new Number(NaN)`
  10. return !isNumber(val) || $isNaN(Number(val));
  11. }
  12. module.exports = isNaN;