function deepClone(obj) {
let result;
if (typeof obj === 'object') {
result = typeof obj.constructor == Array ? [] : {}
for (let i in obj) {
result[i] = typeof obj[i] === 'object' ? deepClone(obj[i]) : obj[i]
}
} else {
result = obj
}
return result
}
深度克隆基本类型函数实现(学习记录)
最新推荐文章于 2024-09-01 10:20:57 发布