function deepClone(oldData){
if(typeof oldData === 'object'&& oldData !== null){
let res = Array.isArray(oldData)?[]:{};
for(let k in oldData)
{
if(oldData.hasOwnProperty(k)){
res[k]= deepclone(oldData[k]);
}
}
return res;
}else{
return oldData;
}
}
通过递归实现深拷贝
于 2024-03-18 10:44:37 首次发布