简单深拷贝

function deepCopy(p, c) {
    var c = c || {};
    for (var i in p) {
      if (typeof p[i] === 'object') {
        c[i] = (p[i].constructor === Array) ? [] : {};
        deepCopy(p[i], c[i]);
      } else {
         c[i] = p[i];
      }
    }
    return c;
  }

  

posted @ 2015-01-09 10:02  ~吉尔伽美什  阅读(152)  评论(0编辑  收藏  举报