Created
September 12, 2019 11:47
-
-
Save NyaGarcia/009c96c8ef445f7bf8931f0ad637d2be to your computer and use it in GitHub Desktop.
Merging object arrays with spread operator
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 pokemon = [ | |
{ name: 'Squirtle', type: 'Water' }, | |
{ name: 'Bulbasur', type: 'Plant' }]; | |
const morePokemon = [{ name: 'Charmander', type: 'Fire' }]; | |
const pokedex = [...pokemon, ...morePokemon]; | |
console.log(pokedex); //Result: [ { 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