I've following scenario where I'm merging two object using Object.assign
function
Object.assign(
{},
{
a:1,
b: {
c:{
d: 1,
e: 1
}
}
},
{
a:2,
b: {
c: {
d:2
}
}
}
);
and getting
{
a: 2,
b: {
c: {
d: 2
}
}
}
but I am expecting to get
{
a: 2,
b: {
c: {
d: 2,
e: 1
}
}
}
I.e., e
should not be eliminated. I want to retain properties in source1
hierarchy that are absent in source2
object hierarchy. Am I using Object.assign
in wrong way?