Created
May 2, 2018 20:42
-
-
Save sarahquigley/1ff1c4a8fbd1efa75ba11972e1b64bbf to your computer and use it in GitHub Desktop.
Example of ES6 Spread Operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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