// 对象深拷贝
const deepClone = function deepClone(obj) {
const c = obj instanceof Array ? [] : {};
Object.entries(obj).forEach((item) => {
const prop = obj[item[0]];
if (typeof prop === 'object') {
if (prop instanceof Array) {
c[item[0]] = [];
prop.forEach((item1) => {
if (typeof item1 !== 'object') {
c[item[0]].push(item1);
} else {
c[item[0]].push(deepClone(item1));
}
});
} else {
c[item[0]] = deepClone(prop);
}
} else {
c[item[0]] = prop;
}
});
return c;
};