// 赋值
var obj2 = obj1;
obj2 .name = ‘aa‘;
这种情况同同时会改变obj1的值;
// Object.assign 是浅拷贝
var obj2 = Object.assign({}, obj1);
obj2 .name = ‘aa‘;
这种情况不会改变obj1的值;
2021-11-26 12:29:44
// 赋值
var obj2 = obj1;
obj2 .name = ‘aa‘;
这种情况同同时会改变obj1的值;
// Object.assign 是浅拷贝
var obj2 = Object.assign({}, obj1);
obj2 .name = ‘aa‘;
这种情况不会改变obj1的值;