Skip to content

arguments Object

The arguments object is an array-like object accessible inside functions that contains all arguments passed to the function. It’s available in regular functions (not arrow functions).

function sum() {
let total = 0;
for (let i = 0; i < arguments.length; i++) {
total += arguments[i];
}
return total;
}
console.log(sum(1, 2, 3, 4)); // 10
function test() {
console.log(arguments.length); // 3
console.log(arguments[0]); // 'a'
console.log(arguments[1]); // 'b'
// ❌ arguments.map is not a function
// ✅ Convert to array
const args = Array.from(arguments);
// or
const args = [...arguments];
}
test('a', 'b', 'c');
const arrowFn = () => {
console.log(arguments); // ReferenceError
};
  • arguments contains all passed arguments
  • It’s array-like (has length, indexed), not a real array
  • NOT available in arrow functions
  • Prefer rest parameters ...args in modern code