Skip to content

Instantly share code, notes, and snippets.

@nate-getch
Created September 5, 2017 22:15
Show Gist options
  • Save nate-getch/d6bdce2d57386a8d60f803ef1234bd6a to your computer and use it in GitHub Desktop.
Save nate-getch/d6bdce2d57386a8d60f803ef1234bd6a to your computer and use it in GitHub Desktop.
Spread and Rest Operator in JS ECMA6
'use strict';
var arr = ['nat', 'gat', 'bat'];
var arr2 = ['dd','bb', ...arr]; // spread
var [a, ...b] = arr; // rest
console.log(arr2); // ["dd", "bb", "nat", "gat", "bat"]
console.log(a); // nat
console.log(b); // ["gat", "bat"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment