<script> Function.prototype.myCall = function () { var arg = Array.prototype.slice.call(arguments) var ctx = arg[0] || window var args = arg.slice(1) ctx._fn = this ctx._fn(... args) delete ctx._fn } Function.prototype.myApply = function () { var arg = Array.prototype.slice.call(arguments) var ctx = arg[0] || window var args = arg[1] || [] ctx._fn = this ctx._fn(... args) delete ctx._fn } Function.prototype.myBind = function () { var arg = Array.prototype.slice.call(arguments) var ctx = arg[0] || window var args = arg.slice(1) ctx._fn = this return function () { args = args.concat(Array.prototype.slice.call(arguments)) ctx._fn(... args) delete ctx._fn } } var b = 'c' var a = { b: 'b', } function m(k, j) { console.log(this.b); console.log(k); console.log(j); } // m('k', 'j') // c k j // m.myCall(a, 'k', 'j') // b k j // m.myApply(a, ['k', 'j']) // b k j // m.myBind(a, 'k')('j') // b k j </script>Copy the code