isArguments.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. var baseIsArguments = require('./_baseIsArguments'),
  2. isObjectLike = require('./isObjectLike');
  3. /** Used for built-in method references. */
  4. var objectProto = Object.prototype;
  5. /** Used to check objects for own properties. */
  6. var hasOwnProperty = objectProto.hasOwnProperty;
  7. /** Built-in value references. */
  8. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  9. /**
  10. * Checks if `value` is likely an `arguments` object.
  11. *
  12. * @static
  13. * @memberOf _
  14. * @since 0.1.0
  15. * @category Lang
  16. * @param {*} value The value to check.
  17. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  18. * else `false`.
  19. * @example
  20. *
  21. * _.isArguments(function() { return arguments; }());
  22. * // => true
  23. *
  24. * _.isArguments([1, 2, 3]);
  25. * // => false
  26. */
  27. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  28. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  29. !propertyIsEnumerable.call(value, 'callee');
  30. };
  31. module.exports = isArguments;