The lodash method _.isArguments exported as a module that checks if value is likely an arguments object.
npx @tessl/cli install tessl/npm-lodash-isarguments@3.1.0The lodash method _.isArguments exported as a module that checks if a value is likely an arguments object. This is a modularized version from the lodash utility library that provides reliable cross-browser detection of JavaScript arguments objects.
npm install lodash.isargumentsvar isArguments = require('lodash.isarguments');For ES modules:
import isArguments from 'lodash.isarguments';var isArguments = require('lodash.isarguments');
// Check arguments objects
(function() {
console.log(isArguments(arguments)); // => true
})(1, 2, 3);
// Check non-arguments objects
console.log(isArguments([1, 2, 3])); // => false
console.log(isArguments({})); // => false
console.log(isArguments('string')); // => false
console.log(isArguments(null)); // => falseThe lodash.isarguments function implements a robust, cross-browser compatible detection strategy for JavaScript arguments objects:
Detection Strategy:
Object.prototype.toString.call(value) === '[object Arguments]' when the environment supports native toStringTag for arguments objectstoStringTag support, falls back to checking the callee property: hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee')Helper Functions:
isObjectLike: Pre-filters values to ensure they are objects (value && typeof value == 'object')isLength: Validates the length property is a valid array-like length (typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER)Cross-Browser Compatibility:
support.argsTag feature detectionChecks if a value is likely an arguments object using cross-browser compatible detection methods.
/**
* Checks if `value` is likely an `arguments` object.
*
* @param {*} value - Any JavaScript value to test for arguments object characteristics.
* Accepts primitives, objects, arrays, functions, null, undefined, etc.
* @returns {boolean} Returns `true` when value is a genuine arguments object from a function call,
* `false` for all other values including arrays, plain objects, and primitives.
*
* @example
* // Arguments object detection
* (function() { return isArguments(arguments); })(); // => true
*
* @example
* // Non-arguments objects
* isArguments([1, 2, 3]); // => false (array)
* isArguments({ '0': 1, length: 1 }); // => false (plain object)
*/
function isArguments(value)Parameters:
value (*): The value to checkReturns:
boolean): Returns true if value is correctly classified as an arguments object, else falseImplementation Details:
The function implements a sophisticated dual-path detection algorithm:
Primary Detection (Modern Environments):
Object.prototype.toString.call(value) === '[object Arguments]' when support.argsTag is availabletoStringTagisObjectLike(value) pre-filtering and isLength(value.length) validationFallback Detection (Legacy Environments):
!support.argsTag (older browsers/engines without native arguments detection)hasOwnProperty.call(value, 'callee') - arguments objects have a callee property!propertyIsEnumerable.call(value, 'callee') - callee should not be enumerableisObjectLike() and isLength() helper validationHelper Function Roles:
isObjectLike(value): Ensures value && typeof value == 'object' to filter out primitivesisLength(value.length): Validates length as valid array-like index (number, >= 0, integer, <= MAX_SAFE_INTEGER)support.argsTag determines which detection path to use automaticallyEdge Cases:
false for arrays, even though they have similar structurefalse for objects that mimic arguments structure (e.g., { '0': 1, 'callee': function() {}, 'length': 1 })false for all primitive values (strings, numbers, booleans)false for null and undefinedUsage Examples:
var isArguments = require('lodash.isarguments');
// Real arguments object
(function() {
return isArguments(arguments); // => true
})();
// Array (false positive check)
isArguments([1, 2, 3]); // => false
// Object that looks like arguments
isArguments({
'0': 1,
'callee': function() {},
'length': 1
}); // => false
// Primitive values
isArguments('string'); // => false
isArguments(42); // => false
isArguments(true); // => false
isArguments(null); // => false
isArguments(undefined); // => false
// Other objects
isArguments(new Date()); // => false
isArguments(new Error()); // => false
isArguments(/regex/); // => false
isArguments(function() {}); // => false