'Merge two object a delete difference
I want to merge two objects to get one final object. the values of the obj2 has to overwrite the values of the obj1 but the final object has to have the same keys as the obj1 (no more, no less) so the keys of the obj2 that don't exist in obj1 have to be deleted.
Here an exemple of what I mean
const obj1 = {
name: "Pauline",
age:20,
city:"Paris"
}
const obj2 = {
name:"Pauline",
age:19,
country:"France"
}
const finalObject = {
nama:"Pauline",
age:19,
city:"Paris"
}
I would appreciate any help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
