Object.assign浅拷贝

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

你可能感兴趣的:(Object.assign浅拷贝)