//深拷贝
export function deepCopy(param) {
if (!Array.isArray(param) && !isObject(param)) {
return param;
} else if (Array.isArray(param)) {
return param.map(item => deepCopy(param));
} else if (isObject(param)) {
let result = {};
Object.keys(param).forEach(key => {
result[key] = deepCopy(param[key]);
});
return result;
}
}
JS深拷贝(封装好,直接可用)
于 2021-07-13 16:33:27 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)