var obj1 = {
name:{
lishishi:'bai'
},
age:12,
sex:['nan','nv'],
no:null
}
const deepClone = (str)=>{
let obj
if(Object.prototype.toString.call(str) === '[object Undefined]')throw new Error('不可进行深拷贝')
if(Object.prototype.toString.call(str) === '[object Null]')return null
Array.isArray(str)?obj = []:obj = {}
for(let key in str){
let val = str[key]
if(typeof val === 'object' && val !== null){
obj[key] = deepClone(val)
}else{
obj[key] = val
}
}
return obj
}
let obj2 = deepClone(obj1)
console.log(obj2)