Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 583 Bytes

no-rest-parameters.md

File metadata and controls

25 lines (17 loc) · 583 Bytes

Forbid the use of rest parameters

Rest parameters can be used to allow any number of parameters to be passed to a function.

Functional programming works better with known and explicit parameters. Having an undefined number of parameters does not work well with currying.

Fail

function sum(...numbers) {
  return numbers.reduce((a, b) => a + b);
}

sum(1, 2, 3);

Pass

function sum(numbers) {
  return numbers.reduce((a, b) => a + b);
}

sum([1, 2, 3]);