SOURCE

Function.prototype.mybind=function(context,...args){
    console.log('bind',...args)

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

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

// printme();
let bindme = printme.mybind(obj,1,2,3);
bindme();
let appleme = printme.myapply(obj,[1,2,3])
let callme = printme.mycall(obj,1,2,3)
console 命令行工具 X clear

                    
>
console