When we assign to obj, we’re always assigning references to addresses, so when we change a value, it’s going to affect that, so we can make a deep copy of the address by checking the type and recursively and when we assign, it’s not going to affect the code
}} function deepCopy(obj = {}){if(typeof obj! == 'object' || obj == null){ return obj } let result if(obj instanceof Array){ result = [] }else{ result = {} } for(let Key in obj){if(obj. HasOwnProperty (key)){result[key] = deepCopy(obj[key])}} return result} obj. Name // 'xiaotri' let obj2 = deepCopy(obj) obj2.name = 'hi' obj2.name // 'hi'Copy the code