**
递归实现对象中有引用数据类型的深拷贝
const obj = {
data: {
name: '小花',
age:undefined,
result: [
'小白',
{
age: 25
}
]
}
}
**
function deep(obj) {
let ArrObj = Array.isArray(obj) ? [] : {}
for (const key in obj) {
if (typeof (obj[key]) == 'object') {
ArrObj[key] = deep(obj[key])
} else {
ArrObj[key] = obj[key]
}
}
return ArrObj;
}
var a1 = deep(obj)
console.log(a1);