SOURCE

// call干了一件什么事情
// 将调用函数作为函数属性赋给this(这里的this是对象参数)
Function.prototype.myCall = function(context){
    if(typeof context=== undefined || context === null){
        return window
    }
    context.fn = this
    let args  = [...arguments].slice(1)
    let result = context.fn(...args)
    delete context.fn
    return result
}

let a  = {s: 'hello world!'}
function say (name){
    console.log(name,this.s)
}
say.myCall(a,'Bob','Tom')

// 引申 apply与call 的区别 
// apply 需要传入的参数是 []
// 所以只需要将上边代码let result = context.fn(...args)中的
// ...args 替换为 args 便是apply的手写
console 命令行工具 X clear

                    
>
console