Created
September 12, 2019 12:07
-
-
Save NyaGarcia/19983a416dd42d76b258b4107f6d36ea to your computer and use it in GitHub Desktop.
Three examples of how the spread operator works with arrays
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 numbers = [1, 2, 3]; | |
console.log(...numbers); //Result: 1 2 3 | |
const pokemon = ['Squirtle', 'Bulbasur', 'Charmander']; | |
console.log(...pokemon); //Squirtle Bulbasur Charmander | |
const pokedex = [ | |
{ name: 'Squirtle', type: 'Water' }, | |
{ name: 'Bulbasur', type: 'Plant' }, | |
{ name: 'Charmander', type: 'Fire' } | |
]; | |
console.log(...pokedex); //{ name: 'Squirtle', type: 'Water' } { name: 'Bulbasur', type: 'Plant' } { name: 'Charmander', type: 'Fire' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment