您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

isNumber.js 886B

1234567891011121314151617181920212223242526272829303132333435363738
  1. var baseGetTag = require('./_baseGetTag'),
  2. isObjectLike = require('./isObjectLike');
  3. /** `Object#toString` result references. */
  4. var numberTag = '[object Number]';
  5. /**
  6. * Checks if `value` is classified as a `Number` primitive or object.
  7. *
  8. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  9. * classified as numbers, use the `_.isFinite` method.
  10. *
  11. * @static
  12. * @memberOf _
  13. * @since 0.1.0
  14. * @category Lang
  15. * @param {*} value The value to check.
  16. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  17. * @example
  18. *
  19. * _.isNumber(3);
  20. * // => true
  21. *
  22. * _.isNumber(Number.MIN_VALUE);
  23. * // => true
  24. *
  25. * _.isNumber(Infinity);
  26. * // => true
  27. *
  28. * _.isNumber('3');
  29. * // => false
  30. */
  31. function isNumber(value) {
  32. return typeof value == 'number' ||
  33. (isObjectLike(value) && baseGetTag(value) == numberTag);
  34. }
  35. module.exports = isNumber;