Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Created September 14, 2019 15:58
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/51ebd5883b5c487e2f359eda6f851683 to your computer and use it in GitHub Desktop.
Save NyaGarcia/51ebd5883b5c487e2f359eda6f851683 to your computer and use it in GitHub Desktop.
Merging objects with the spread operator
const baseSquirtle = {
name: 'Squirtle',
type: 'Water'
};
const squirtleDetails = {
species: 'Tiny Turtle Pokemon',
evolution: 'Wartortle'
};
const squirtle = { ...baseSquirtle, ...squirtleDetails };
console.log(squirtle); //Result: { name: 'Squirtle', type: 'Water', species: 'Tiny Turtle Pokemon', evolution: 'Wartortle' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment