isArguments.js 955 B

12345678910111213141516171819202122232425262728293031323334
  1. import isArrayLike from '../internal/isArrayLike';
  2. import isObjectLike from '../internal/isObjectLike';
  3. /** Used for native method references. */
  4. var objectProto = Object.prototype;
  5. /** Used to check objects for own properties. */
  6. var hasOwnProperty = objectProto.hasOwnProperty;
  7. /** Native method references. */
  8. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  9. /**
  10. * Checks if `value` is classified as an `arguments` object.
  11. *
  12. * @static
  13. * @memberOf _
  14. * @category Lang
  15. * @param {*} value The value to check.
  16. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
  17. * @example
  18. *
  19. * _.isArguments(function() { return arguments; }());
  20. * // => true
  21. *
  22. * _.isArguments([1, 2, 3]);
  23. * // => false
  24. */
  25. function isArguments(value) {
  26. return isObjectLike(value) && isArrayLike(value) &&
  27. hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
  28. }
  29. export default isArguments;