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

isString.js 723B

123456789101112131415161718192021222324252627282930
  1. var baseGetTag = require('./_baseGetTag'),
  2. isArray = require('./isArray'),
  3. isObjectLike = require('./isObjectLike');
  4. /** `Object#toString` result references. */
  5. var stringTag = '[object String]';
  6. /**
  7. * Checks if `value` is classified as a `String` primitive or object.
  8. *
  9. * @static
  10. * @since 0.1.0
  11. * @memberOf _
  12. * @category Lang
  13. * @param {*} value The value to check.
  14. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  15. * @example
  16. *
  17. * _.isString('abc');
  18. * // => true
  19. *
  20. * _.isString(1);
  21. * // => false
  22. */
  23. function isString(value) {
  24. return typeof value == 'string' ||
  25. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  26. }
  27. module.exports = isString;