SOURCE

const deepClone = function(obj){
    let newObj = Array.isArray(obj) ? [] : {};
    
    for(let item in obj){
       newObj[item] = 
       typeof obj[item] === 'object' 
       ? deepClone(obj[item]) 
       : obj[item]; 
    }
    return newObj;
}

let person = {
	name:'abc',
	age:16,
	hobbies:['basketball','volleyball'],
    son:{
        name:'ccc',
        age:11
    }
}

const newPerson = deepClone(person);

console.log(newPerson)
console.log(person)
console 命令行工具 X clear

                    
>
console