对象浅拷贝Object.assign

const target = {
   a: {
      b: {
         c: {
            d: 1
         }
      },
      e: 5,
      f:  6,
      h: 10
   }
}
const source = {
   a: {
      b: {
         c: {
            d: 1
         }
      },
      e: 2,
      f: 3
   }
}
Object.assign(target, source)
console.log(target)

猜你喜欢

转载自www.cnblogs.com/qjb2404/p/12209322.html