// js 深拷贝

function deepCopy(obj) {
   var result = Array.isArray(obj) ? [] : {};
   for (var key in obj) {
      if (obj.hasOwnProperty(key)) {
         if (typeof obj[key] === 'object' && obj[key]!==null) {
             result[key] = deepCopy(obj[key]); //递归复制
         } else {
          result[key] = obj[key];
        }
     }
  }
  return result;
}

// 通过json的方式实现

function (obj) {

  let tmp = JSON.stringify(obj);

JSON.parse(tmp); 

  return result
}



相关文章:

  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
猜你喜欢
  • 2021-03-31
  • 2021-09-23
  • 2022-01-25
相关资源
相似解决方案