数组及对象深拷贝 var arr = [1,'2',{a:1,b:[1,2]}]; function deepCopy(p, c) { var c = c || {}; for (var i in p) { if (typeof p[i] === 'object' && p[i] !== null) { c[i] = (p[i].constructor === Array) ? [] : {}; deepCopy(p[i], c[i]); } else { c[i] = p[i]; } }