shallow merge javascript code example
Example: javascript object shallow merge
var obj1 = {
foo: {
prop1: 42,
},
};
var obj2 = {
foo: {
prop2: 21,
},
bar: {
prop3: 10,
},
};
var result = {
foo: { // `foo` got overwritten with the value of `obj2`
prop2: 21,
},
bar: {
prop3: 10,
},
}