SOURCE

//手写call

Function.prototype.mycall = function(context){
    if(typeof context ==null || typeof context ==undefined){
        context = window;
    }
    context.fn = this;
    let args = Array.from(arguments).slice(1);
    let res = context.fn(...args);
    delete context.fn;
    return res;
}

function me(){
    console.log(this);
}
let o1={a:1,name:'o1'};
let o2 = {a:2,name:'o2'};
me.mycall(o2)
console 命令行工具 X clear

                    
>
console