function deepClone(obj) {
if (typeof obj !== 'object' || obj === null) {
return obj;
}
const newObj = Array.isArray(obj) ? [] : {};
for (let key in obj) {
newObj[key] = deepClone(obj[key]);
}
return newObj;
}
js 最简洁的深拷贝方法
最新推荐文章于 2024-08-04 16:33:59 发布