I have two objects. And I want to merge the two objects but only the property value who is only present to the first object.
obj1 : {
"name": "",
"age": ""
}
obj2 : {
"name": "Leo",
"age": "14",
"company": "aero",
"shift": "night"
}
The output I want to be is:
obj1 : {
"name": "Leo",
"age": "14"
}
The company
and shift
is no need to merge because that 2 property is not present in obj1
.
The code I've done so far is:
Object.assign({}, obj1, obj2);
But it's not give me the right output. What it gives is:
merge : {
"name": "Leo",
"age": "14",
"company": "aero",
"shift": "night"
}
Could someone help me how to achieve the output like this:
merge : {
"name": "Leo",
"age": "14",
}
Many thanks!