Given I have the following object:
let obj = {
cat: "paws",
dogs: {
lab: "Christopher",
otherLab: "Lady Buba"
}
}
let objTwo = {
dogs: {
lab: "some new name"
}
}
How can I merge the above two objects so that the final result is:
{
cat: "paws",
dogs: {
lab: "some new name",
otherLab: "Lady Buba"
}
}
I've attempted to use spread operators with let finalObj = {...obj, ...objTwo}
, but this entirely replaces the value of dogs, so that the end result is:
{
cat: "paws",
dogs: {
lab: "some new name",
}
}
which isn't what I want.