Here's a shorter version of bind than the one I mentioned from the book - it gets rid of the unnecessary loops.
Code:
if (!Function.prototype.bind) {
Function.prototype.bind = function(o) {
var self, bndargs;
self = this;
bndargs = Array.prototype.slice.call(arguments);
bndargs.shift();
return function() {
var args = bndargs.concat(Array.prototype.slice.call(arguments));
return self.apply(o, args);
};
};
};