/**
* 深拷贝
* @param {Object} obj 拷贝对象
*/
export const deepCopy = (obj) => {
let result = isArray(obj) ? [] : {}
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
if (typeof obj[key] === 'object' && obj[key] !== null) {
result[key] = deepCopy(obj[key]) //递归复制
} else {
result[key] = obj[key]
}
}
}
return result
}
深拷贝方法
最新推荐文章于 2023-07-25 19:00:38 发布