<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

    // 手写bind
    Function.prototype.bind1 = function (){
      // 将参数转化未数组
      const args = Array.prototype.slice.call(arguments);

      const t = args.shift();

      const self = this;

      return function (){
        self.apply(t, args);

    function fn1(a, b, c){
      console.log(a, b, c);
      console.log("this", this);

    let fn2 = fn1.bind1({name:'Tom'}, 10, 20, 30)

Last modification:October 28th, 2020 at 10:13 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment