Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Created September 12, 2019 11:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NyaGarcia/009c96c8ef445f7bf8931f0ad637d2be to your computer and use it in GitHub Desktop.
Save NyaGarcia/009c96c8ef445f7bf8931f0ad637d2be to your computer and use it in GitHub Desktop.
Merging object arrays with spread operator
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