export function deepClone(source) {
if (!source && typeof source !== "object") {
throw new Error("error arguments", "deepClone");
}
const targetObj = source.constructor === Array ? [] : {};
Object.keys(source).forEach(keys => {
if (source[keys] && typeof source[keys] === "object") {
targetObj[keys] = deepClone(source[keys]);
} else {
targetObj[keys] = source[keys];
}
});
return targetObj;
}
07-20
7480
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-13
982
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-16
1654
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-18
2776
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)