1. call Function.prototype.myCall = function (context) { // context 接收第一个参数 如果没有默认用window context = context || window // 给context.fn 或其他属性赋值为函数, 即myCall的调用者改变函数的this 指向context context.fn = this // 获取传入的参数 const args = [...arguments].slice(1) // 通过...展开并传给fn args 获取执行结果 result 并返回 const result = context.fn(...args) // 删除fn delete context.fn return result } 2. apply Function.prototype.myApply = function (context) { context = context || window context.fn = this let result if (arguments[1]) { result = context.fn(...arguments[1]) } else { result = context.fn() } delete context.fn return result } 3. bind Function.prototype.myBind = function (context) { context = context || window const args = [...arguments].slice(1) let _this = this return function f () { return _this.apply(context, [...args, ...arguments]) } }