topic description
es6 assign object is shallowly copied, and the attribute value of the target object does not change.
sources of topics and their own ideas
after learning es6 assign, I know it is a shallow copy, but there is a strange phenomenon in practice
related codes
/ / Please paste the code text below (do not replace the code with pictures)
const obj1 = {a: {b: 1}, c:3};
const obj2 = Object.assign({}, obj1);
obj1.a.b = 2;
obj1.c=8
console.log(obj2); // {a: {b: 2}, c:3}
Why has the value of c not changed? Isn"t a shallow copy a reference to a copy?