Skip to content

arguments

Reports using the arguments object instead of rest parameters.

✅ This rule is included in the ts logical presets.

The arguments object is an array-like object available in non-arrow functions that contains the values of the arguments passed to the function. However, it lacks Array methods like map, filter, and forEach, making it inconvenient to work with. Rest parameters provide a real Array, which is more versatile and easier to use.

function sum() {
let total = 0;
for (let i = 0; i < arguments.length; i++) {
total += arguments[i];
}
return total;
}
function logAll() {
console.log(arguments);
}

This rule is not configurable.

If you need to support environments that don’t have rest parameter syntax, such as ES5 or earlier, you may need to disable this rule. However, most modern JavaScript environments support rest parameters.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.