SOURCE

//call
Function.prototype.mycall=function(context,...args){
    context = context || window;
    context.fn=this;
    let res = context.fn(...args)
    delete context.fn;
    return res;
}
Function.prototype.myapply=function(context,...args){
    context = context ||window;
    context.fn = this;
    let res =context.fn(...args)
    delete context.fn;
    return res;
}
Function.prototype.mybind = function(context,...args){
    context = context ||window;
    context.fn = this;
    return function(...newArgs){
        let res = context.fn(...args,...newArgs);
        delete context.fn;
        return res;
    }
}

function printme(a,b,c,d){
    console.log(this,a,b,c,d);
}
let obj={
    a:1,
    b:2
}
printme.mycall(obj,1,2,3)

let bin = printme.mybind(obj,1,2,3)
bin(4)
console 命令行工具 X clear

                    
>
console