SOURCE

Function.prototype.myCall= function(obj,...args){
        const fn = Symbol('fn')        // 声明一个独有的Symbol属性, 防止fn覆盖已有属性
        obj = obj||window //  若没传入,则默认绑定window对象
        obj[fn] = this
        let result = obj[fn](...args)
        delete obj.fn
        return result
    }

function foo(c){
    console.log(this.a,c)
    return c
}

let a = {
    a:1,
    b:2
}

console.log(foo.myCall(a,3))
console 命令行工具 X clear

                    
>
console