Rest parameters

Treats arguments as an array

  1. function foo(...bar) {
  2. console.log(bar.join(' ')); // Logs 'I can haz teh arguments'
  3. }
  4. foo('I', 'can', 'haz', 'teh', 'arguments');

rules

  1. It is like arguments but the rest parameters is a real array.
  2. You just can have one rest parameter per function and has to be in the last position.
  3. You can’t use arguments