25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
682 B

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