// 深拷贝
function dishesStackHandle(person, current) {
var current = current || {};
for (var i in person) {
if (typeof person[i] === 'object') {
if (i == 'null' || i == null || person[i] == null) {
current[i] = {};
} else {
current[i] = (person[i].constructor === Array) ? [] : {};
}
dishesStackHandle(person[i], c[i]);
} else {
current[i] = person[i];
}
}
return current;
}
//递归拷贝
function deepCopy(obj) {
var result = Array.isArray(obj) ? [] : {};
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'object') {
result[key] = deepCopy(obj[key]); //递归复制
} else {
result[key] = obj[key];
}
}
}
return result;
}