Skip to content

Instantly share code, notes, and snippets.

@sarahquigley
Created May 2, 2018 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sarahquigley/1ff1c4a8fbd1efa75ba11972e1b64bbf to your computer and use it in GitHub Desktop.
Save sarahquigley/1ff1c4a8fbd1efa75ba11972e1b64bbf to your computer and use it in GitHub Desktop.
Example of ES6 Spread Operator
/* ES5 */
var cats = [ 'Maru', 'Colonel Meow', 'Grumpy Cat' ];
var moreCats = [ 'Shironeko', 'Zarathustra'].concat(cats);
// > [ 'Shironeko', 'Zarathustra', 'Maru', 'Colonel Meow', 'Grumpy Cat' ]
/* >= ES6 */
var cats = [ 'Maru', 'Colonel Meow', 'Grumpy Cat' ];
var moreCats = [ 'Shironeko', 'Zarathustra', ...cats ];
// > [ 'Shironeko', 'Zarathustra', 'Maru', 'Colonel Meow', 'Grumpy Cat' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment