| 1.什么是柯里化?通俗的讲,就是 只传递给函数一部分参数来调用它,让它返回一个函数来处理剩下的参数 的一种技术,下面举个简单的例子。
  
    function add(x,y){
      return x+y
    }
 我们将该函数进行柯里化处理  
    function Currying(x){
      return function(y){
        return x+y
      }
    }
 
   function add(){
      
      const _arg = [...arguments];
      const fn1 = function(){
        
        _arg.push(...[...arguments])
        
        return fn1
      }
      fn1.result=function(){
        return _arg.reduce((pre,cur)=>{
          return pre+cur
        })
      }
      return fn1
    }
    const res = add(1)(2)(3)(4)(5).result()  
 bind()函数实现的机制就是柯里化,下面我们来实现一个bind函数:  Function.prototype.myBind = function(){
      
      const _this = this;
      if(typeof this !== 'function') throw Error('TypeError: xx must be a function')
      
      const firstParam = [...arguments][0];
      
      const remainingParam = [...arguments].slice(1)
      return function(){
        _this.apply(firstParam,[...arguments].push(...remainingParam))
      }
    }
 |