What is the arguments object in JavaScript?
Answer
The arguments object is an array-like object available inside regular functions (not arrow functions) containing all passed arguments, regardless of the function's parameter count. function sum() { return Array.from(arguments).reduce((a, b) => a + b, 0); }. It has a length property and numeric indices but lacks array methods (map, filter, etc.) — convert with Array.from(arguments) or [...arguments]. In ES6, rest parameters (...args) are the modern replacement — they are actual arrays: function sum(...args) { return args.reduce((a, b) => a + b, 0); }. Arrow functions do NOT have their own arguments object — they inherit it from the enclosing regular function's scope. In strict mode, arguments does not track changes to named parameters. Always prefer rest parameters over arguments in modern code — they are clearer, are real arrays, and work in arrow functions.
Previous
What is an IIFE (Immediately Invoked Function Expression)?
Next
What is short-circuit evaluation in JavaScript?