1.
// 深拷贝
function deepclone(obj){
let newobj=Array.isArray(obj)?[]:{}
for(let key in obj){
if(typeof obj[key]==='object'){
newobj[key]=deepclone(obj[key])
}else{
newobj[key]=obj[key]
}
}
return newobj
}
2.
let obj2=JSON.parse(JSON.stringify(obj1))
标签:obj,newobj,JSON,let,key,拷贝,js From: https://www.cnblogs.com/sun-shuaichao/p/16727719.html