Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For partial argument binding, I find myself using an implementation that doesn't close 'this' much more often. E.g.

  Function.prototype.partial = function () {
    var 
      fn = this,
      args = Array.prototype.slice.call(arguments)
    ;
    return function() { 
      var newArgs = Array.prototype.slice.call(arguments);
      return fn.apply(this,args.concat(newArgs));
    }
  }


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: