Created
September 14, 2019 15:58
-
-
Save NyaGarcia/51ebd5883b5c487e2f359eda6f851683 to your computer and use it in GitHub Desktop.
Merging objects with the 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 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