function deepClone(value){ const map=new WeakMap() function _deepClone(value){ if(value===null || typeof value !== 'object'){ return value } if(map.has(value)){ return caches.get(value) } const result=Array.isArray(value)?[]:{} map.set(value,result) for(let key in value){ if(value.hasOwnProperty(key)){ result[key]==_deepClone(value[key]) } } return result; } return _deepClone(value) }