js对象深拷贝

// 对象深拷贝
objDeepCopy(source) {
  let sourceCopy = source instanceof Array ? [] : {};
  for (let item in source) {
    sourceCopy[item] = typeof source[item] === 'object' ? this.objDeepCopy(source[item]) : source[item];
  }
  return sourceCopy;
},

 

posted @ 2021-11-02 14:04  ALin_Da  阅读(35)  评论(0编辑  收藏  举报