深拷贝
2023-03-06 10:36:36
ts
function deepClone(source) {
const target = {}
for (property in source) {
if (typeof source[property] === 'object') {
target[property] = deepClone(source[property])
} else {
target[property] = source[property]
}
}
return target
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11