Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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