📜  javascript 对象浅合并 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:39.853000             🧑  作者: Mango

代码示例1
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,
  },
}