SOURCE

var object = {
    name:1,
    age:2
}

var o = {

}

var d = Object.assign(o,object)

var deepCopy = function(newObject,oldObject){
    for(let k in oldObject){
        let item = oldObject[k]
        if(item instanceof Array){
            newObject[k] = []
            deepCopy(newObject[k],item)
        } else if(item instanceof Object){
            newObject[k] = {}
            deepCopy(newObject[k],item)
        }else{
            newObject[k] = oldObject[k]
        }
    }
    return newObject
}

var da = deepCopy(o , object)
console.log(da)
console 命令行工具 X clear

                    
>
console