function deepclone(obj){
if(typeof(obj)!='object'||obj==null){
return obj;
}
let result;
if(obj instanceof Array){
result=[];
}else{
result={};
}
for(let key in obj){
if(obj.hasOwnProperty(key)){
result[key]=deepclone(obj[key])
}
}
return result;
}
let obj1={
dd:1,
xxx:'erere',
arr:[1,3,4],
objxxx:{
xx1:'w',
xxd:{
dd:2
}
}
}
let obj2=deepclone(obj1);
obj2.arr[2]='222';
console.log(obj2);
console.log(obj1);