SOURCE

function deepClone(obj){
    let result = {}
    let keys = Object.keys(obj)
    console.log(keys)
    for(let i=0;i< keys.length;i++){
        if(typeof(obj[keys[i]]) === 'string'||typeof(obj[keys[i]])=== 'number'||typeof(obj[keys[i]])=== 'boolean'){
            result[keys[i]] = obj[keys[i]]
        }else{
           result[keys[i]] = deepClone(obj[keys[i]])
        }
    }
    return result
}

let name = {'firstname':'roc', 'lastname':'zhang','grade':[1,2,3]}
let nameCopy = deepClone(name)
let arr = {0:1,1:2,2:4}

console.log(nameCopy.firstname)
console.log(nameCopy.lastname)



console 命令行工具 X clear

                    
>
console