改变了原对象obj1 = {a:1,b:{b1:1}}
obj2 = Object.assign({},obj1)
obj2.b.b1=2console.log(obj1.b.b1)// 2obj1 = {a:1,b:{b1:1}}
obj2 = Object.assign({},obj1,{})
obj2.b.b1=2console.log(obj1.b.b1)// 2未改变原对象obj1 = {a:1,b:{b1:1}}
obj2 = {a:2,b:{b1:2}}
obj3 = Object.assign({},obj1,obj2)
obj3.b.b1=8console.log(obj1.b.b1)// 1
添加回答
举报
0/150
提交
取消