Object.assign浅拷贝
2019-07-11 本文已影响0人
番茄番茄茄
const target = { a: 1, b: 2 };
const source = { b: 4, c: 5 ,a:4};
console.log(target);
const returnedTarget = Object.assign(target, source);
console.log(target);
// expected output: Object { a: 1, b: 4, c: 5 }
console.log(returnedTarget);
// expected output: Object { a: 1, b: 4, c: 5 }
console.log(source);
image.png