1. ES5实现 ```javascript (function(){ if (!Function.prototype.bind) { let slice = Array.prototy.slice

      1. Funcion.prototype.bind = function() {

      let that = this; let context = arguments[0]; if (typeof that !== ‘function’) {

      1. throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable")

      }

      1. let outerArgs = slice.call(arguments, 1);

      return function() {

      1. let innerArgs = slice.call(arguments);
      2. let allArgs = outerArgs.concat(innerArgs);
      3. return context.apply(that, allArgs)

      ; }

      } } })()

    1. 2. ES6实现
    2. ```javascript
    3. (function() {
    4. if(!Function.prototype.bind) {
    5. Function.prototype.bind = function(context, ...outerArgs) {
    6. let that = this;
    7. if(typeof that !== 'function') {
    8. throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
    9. }
    10. return function(innerArgs) {
    11. return that.apply(context, [...outerArgs, ...innerArgs]);
    12. }
    13. }
    14. }
    15. })()