var a = {
key1:"11111"}
function Copy(p, c) {
var c = c || {};
for (var i in p) {
if (typeof p[i] === 'object') {
c[i] = (p[i].constructor === Array) ? [] : {};
Copy(p[i], c[i]);
} else {
c[i] = p[i];
}
}
return c;
}
a.key2 = ['小辉','小辉'];
var b={};
b = Copy(a,b);
console.log(b) // {key1: "11111", key2: ['小辉','小辉']} 为什么会是这个结果?主要是不明白key2是怎么来的?
牛奶老哥哥
慕的地6079101
qq_Dreamy_旧城_0
情若自控3943916
相关分类