3 ms·
ok, but once you start using closures everywhere someone has the bright idea to abstract most of that code into a utility function. before you know it, you're b
by diN0bot 17y ago
ok, but once you start using closures everywhere someone has the bright idea to abstract most of that code into a utility function. before you know it, you're back to bind.
function _bind(o, m) {
var bound_arguments = Array.prototype.slice.apply(arguments, [2]);
return function() {
var now_arguments = Array.prototype.slice.apply(arguments);
var args = bound_arguments.slice().concat(now_arguments);
return m.apply(o, args);
}
}
- bumblebird 17y agoAbstracting out "function(c){return function(){/stuff/}}(this)" seems like overkill to me. I guess it's a matter of taste etc.