编辑代码

Function.prototype.bind2 = function(context,...args){
    let cont = context || window;
    cont.fn = this;
    let res;
    if(!args){
        res = cont.fn;
    }else{
        res = cont.fn(...args);
    }
    delete cont.fn;
    return function(){
        return res
    }
}
let obj = {
    value:1
}
function bar(name,age){
    return {
        value:this.value,
        name:name,
        age:age
    }
}
console.log(bar.bind2(obj,'kevin',16)())