// 解决 堆栈 出现的父对象和子对象相关联的问题
function dishesStackHandle(p, c) {
var c = c || {};
for (var i in p) {
if (typeof p[i] === ‘object‘) {
if (i == ‘null‘ || i == null || p[i] == null) {
c[i] = {};
} else {
c[i] = (p[i].constructor === Array) ? [] : {};
}
dishesStackHandle(p[i], c[i]);
} else {
c[i] = p[i];
}
}
return c;
}
原文地址:https://www.cnblogs.com/yangsg/p/10148505.html
时间: 2024-11-05 22:03:10