Last active
August 25, 2022 22:03
-
-
Save Naedri/3bbe7a3d0af6be05b61694e0fdd4e298 to your computer and use it in GitHub Desktop.
Objects concatenation with redondant values.
This file contains 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
let obj1, obj2, obj3; | |
/** | |
* spread_synthax | |
*/ | |
//with non redondant values, everyone stay | |
obj1 = { food: 'pizza', car: 'ford' }; | |
obj2 = { animal: 'dog' }; | |
obj3 = { ...obj1, ...obj2 }; | |
console.log(obj3); // => { food: "pizza", car: "ford", animal: "dog" } | |
//with redondant values, the last stays | |
obj1 = { food: 'pizza', car: 'ford', animal: 'human' }; | |
obj2 = { animal: 'dog' }; | |
obj3 = { ...obj1, ...obj2 }; | |
console.log(obj3); // => { food: "pizza", car: "ford", animal: "dog" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment