export function deepClone(data) {
if (typeof data !== 'object' || typeof data == 'function' || data === null) {
return data
}
let item
if (Array.isArray(data)) {
item = []
}
if (!Array.isArray(data)) {
item = {}
}
for (let i in data) {
if (Object.prototype.hasOwnProperty.call(data, i)) {
item[i] = deepClone(data[i])
}
}
return item
}
网友评论