Skip to content

Latest commit

 

History

History
14 lines (9 loc) · 300 Bytes

restSyntax.md

File metadata and controls

14 lines (9 loc) · 300 Bytes

Rest syntax

Rest syntax is the inverse of spread syntax. It is taking data and putting it into an array.

function addOne(...numbers){
  return numbers.map(n => n + 1);
}

const foo = addOne(1,2,3,4,5); // [1,2,3,4,5]

const [a,b,...rest] = [1,2,3,4] // a: 1, b: 2, rest: [3,4]