function deepClone(obj, hash = new WeakMap()) {if (obj === null) return objif (obj instanceof Date) return new Date(obj)if (obj instanceof RegExp) return new RegExp(obj)if (typeof obj !== 'object') return objif (hash.get(obj)) return hash.get(obj)let newObj = new obj.constructor()hash.set(obj, newObj)for (let key of Object.keys(obj)) {newObj[key] = deepClone(obj[key], hash)}return newObj}
