深拷贝

deepClone: function (obj, map = new Map()) {
    if (typeof obj === 'object') {
      const res = Array.isArray(obj) ? [] : {}
      if (map.get(obj)) return map.get(obj)
      map.set(obj, res)
      for (const item in obj) {
        res[item] = this.deepClone(obj[item], map)
      }
      return res
    } 
return obj },
原文地址:https://www.cnblogs.com/guoguocode/p/14684597.html