SOURCE

function deepClone(obj){
    if(typeof obj !== "object" || typeof obj === "function"){
        return obj
    }
    else if(obj === null || undefined){
        return obj
    }
    let newObj
    if(Array.isArray(obj)){
        newObj = []
    }else if(obj instanceof Object === true){
        newObj = {}
    }
    
    for(let key in obj){
        newObj[key] = deepClone(obj[key])
    }

    return newObj
}
let a = {
    b: '11',
    c: 'sda',
    d: {
        e:1,
        f:{
            g: 1
        } 
    },
    h: null,
    i: undefined,
    j: [1, 2, 3],
    k: () => {}
}
let b = 1

console.log(deepClone(a))
console.log(JSON.parse(JSON.stringify(a)))
console 命令行工具 X clear

                    
>
console