深拷贝
function deepClone(source) {
if (typeof source === 'object') {
const target = Array.isArray(source) ? [] : {}
for (let key in source) {
if (source.hasOwnProperty(key)) {
target[key] = deepClone(source[key])
}
}
return target
} else {
return source
}
}