function deepClone(Obj){
let newObj = Array.isArray(Obj)?[]:{};
if(Obj&&typeof Obj === 'object'){
// for ...in...会把继承属性一起遍历
for(let key in Obj){
if(Obj[key]&&typeof Obj[key] ==='object'){
newObj[key]=deepClone(Obj[key])
}else{
newObj[key]=Obj[key]
}
}
}
return newObj
}
const a={
c:23234,
k:true,
ads:()=>{
console.log(123)
},
jk:{
name:'zasdfadfa',
ccc:()=>{
console.log('ladjflkxcjlv')
}
}
}
console.log(a.jk.ccc(),'aaaa')
console.log(deepClone(a).jk.ccc(),'cloneaaaa')