SOURCE

function DeepCopy(a, b){
    if(!b || typeof b !== 'object'){
        return
    }
    if(!a || typeof a !== 'object'){
        return
    }
    for(var key in b){
        if(b.hasOwnProperty(key)){
            if(b[key] && typeof b[key] === 'object'){
                a[key] = Array.isArray(b.key) ? [] : {}
                DeepCopy(a[key], b[key])
            }else{
                a[key] = b[key]
            }
        }
    }
} 
var m = {
    n: 1,
    d: {
        o: 2
    }
}
var new1 = {};
DeepCopy(new1, m)
console.log(new1)
console.log(m)
console 命令行工具 X clear

                    
>
console