Last active
July 25, 2018 09:27
-
-
Save aderaaij/13f737d5630db2e1cf46a9fbe0fccb9f to your computer and use it in GitHub Desktop.
The spread operator can expand(spread) any iterable like an array or a string.
This file contains hidden or 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
| const avengers = ['Thor', 'The Hulk', 'Captain America']; | |
| const guardians = ['Star Lord', 'Gamorra', 'Drax', 'Rocket', 'Groot']; | |
| // Spread out arrays in a new array and put a new value in between them | |
| const heroes = [...avengers, 'Loki', ...guardians]; | |
| // Adding some new values to it just got easier | |
| const guardiansVol2 = [...guardians, 'Mantis', 'Yondu', 'Nebula']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment