此方法不推荐使用
let obj = {
name: {
a: 'f',
b: 'fg'
},
hellio: {
d:'vv',
s:'cc'
}
}
let copyObj = Object.assign(obj, {c:'huu'})
console.log(copyObj);
console.log(obj);
推荐使用方法
let copyObj = {...obj, c:'huu'};
console.log(copyObj);
console.log(obj);
let test = {
k:'p',
d:'b'
}
let copyObj = {...obj, ...test};
console.log(copyObj);
console.log(obj);