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]);// 这里为什么不写成c[i]=Copy(p[i], c[i]); } else { c[i] = p[i]; } } return c;}a.key2 = ['小辉','小辉'];var b={};b = Copy(a,b); console.log(b)
添加回答
举报
0/150
提交
取消