SOURCE

Function.prototype.bind_self = function(obj,...args){
    if(typeof this !== 'function'){
        console.log('error')
    }
    let that = this
    function fbind(...newArgs){
        let totalArgs = args.concat(newArgs)
        that.apply(obj,totalArgs)
    }

    function fOP(){

    }
    // shim new 的情况
    fOP.prototype = this.prototype
    fbind.prototype = new fOP()
    return fbind
}

var fn = function(){
    console.log(this.name)
}

let fn_copy = fn.bind_self({ name:'lily'})
fn_copy()

fn()


console 命令行工具 X clear

                    
>
console