SOURCE

Object.defineProperty(Object,'assign2',{
    value: function(target,...args){
        if(target===null){
            throw new Error('不支持null和undefine')
        }
        //转成引用了型
        const to = Object(target)
        for(let i=0;i<args.length;i++){
            let nextSource = args[i]
            for(let nextKey in nextSource){
                if(nextSource.hasOwnProperty(nextKey)){
                    to[nextKey] = nextSource[nextKey]
                }
           }
        }
        return to
    },
    enumerable: false,
    configurable: true,
    writable: true
})

console.log(Object.assign2({c:4},{a:1},{b:2}))
console 命令行工具 X clear

                    
>
console