Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 750 Bytes

no-rest-parameter.md

File metadata and controls

24 lines (17 loc) · 750 Bytes

Disallow usage of the rest parameter syntax (no-rest-parameter)

The rest parameter syntax was introduced in ES6. In older browsers, this syntax is transpiled down to ES5. The resulting code loops over arguments to create a new array object, which causes performance issues. If your app supports older browsers, copy arguments using Array.prototype.slice instead.

Rule details

Example of incorrect code:

function foo(...args) {
    console.log(args);
}

Example of correct code:

const ArraySlice = Array.prototype.slice;

function foo() {
    const args = ArraySlice.call(arguments, 0);
    console.log(args);
}