Answers for "javascript object shallow merge"

0

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,
  },
}
Posted by: Guest on July-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language