判断类型见:https://www.cnblogs.com/zhoulixue/p/17187385.html
// 深拷贝 export const deepclone = (source: any) => { if (getType(source) === 'Object') { return Object.keys(source).reduce((pre, curr) => { const res = pre; res[curr] = deepclone(source[curr]); return res; }, {}); } if (getType(source) === 'Array') { return source.map((x: any) => deepclone(x)); } if (getType(source) === 'Date') { return new Date(source); } if (getType(source) === 'RegExp') { return new RegExp(source.source, source.flags); } return source; };
标签:常用,return,函数,res,getType,deepclone,source,curr,拷贝 From: https://www.cnblogs.com/zhoulixue/p/17187402.html