function deepClone(obj = {}) {
// 如果是不需要克隆的类型直接返回
if(typeof obj !== 'object' || obj === null) {
return obj
}
// 根据是数组or对象初始化结果值
let result
if(obj instanceof Array) {
result = []
} else {
result = {}
}
// 递归拷贝
for(key of obj) {
result[key] = deepClone(obj[key])
}
return result
}