深复制
// 深复制
let deepCopy = (data) => {
let result = Array.isArray(data)?[]:{};
if (typeof data === 'object') {
if (JSON) {
result = JSON.parse(JSON.stringify(data));
} else {
for (let i in data) {
result[i] = typeof data[i] === 'object' ? deepCopy(data[i]) : data[i];
}
}
}
return result;
};