You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 regels
911 B

3 jaren geleden
  1. var isNumber = require('./isNumber');
  2. /**
  3. * Checks if `value` is `NaN`.
  4. *
  5. * **Note:** This method is based on
  6. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  7. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  8. * `undefined` and other non-number values.
  9. *
  10. * @static
  11. * @memberOf _
  12. * @since 0.1.0
  13. * @category Lang
  14. * @param {*} value The value to check.
  15. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  16. * @example
  17. *
  18. * _.isNaN(NaN);
  19. * // => true
  20. *
  21. * _.isNaN(new Number(NaN));
  22. * // => true
  23. *
  24. * isNaN(undefined);
  25. * // => true
  26. *
  27. * _.isNaN(undefined);
  28. * // => false
  29. */
  30. function isNaN(value) {
  31. // An `NaN` primitive is the only value that is not equal to itself.
  32. // Perform the `toStringTag` check first to avoid errors with some
  33. // ActiveX objects in IE.
  34. return isNumber(value) && value != +value;
  35. }
  36. module.exports = isNaN;