A == null; a == null; WeakMap() function deepClone(Origin, hashMap = new WeakMap()){ if (origin == undefined || typeof origin ! == 'object'){ return origin; If (origin instanceof Date){return new Date(origin); If (origin instanceof RegExp){return new RegExp(origin); } / / {} [] / / was through the Object. The prototype. Judging the toString is an array or Object, Const hasKey = hashmap.get (origin); // Const hasKey = hashmap.get (origin); if (hasKey){ return origin; } const target = new origin.constructor(); hashMap.set(origin, target); For (const k in origin){if (origine.hasownProperty (k)){// Direct target[k] = deepClone(Origin [k], hashMap); }} return target} const obj1 = {name: 'job ', age: '18', job: [' job ', 'js', {web:' HTML ', web_style: 'CSS'}], hobby: {ball: 'master ', cats:' site '}} const obj2 = deepClone(obj1); console.log(obj1); obj2.age = 22; obj2.job[2].web = 'xml'; console.log(obj2); const obj3 = {} const obj4 = {} obj3.obj4 = obj4 obj4.obj3 = obj3 console.log(obj3) console.log(obj4)Copy the code