Skip to content

Instantly share code, notes, and snippets.

@dsc
Created November 8, 2011 22:17
Show Gist options
  • Save dsc/1349461 to your computer and use it in GitHub Desktop.
Save dsc/1349461 to your computer and use it in GitHub Desktop.
Function.prototype.bind
// See https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
// for a more verbose-but-standards-compliant version.
if (!Function.prototype.bind) {
Function.prototype.bind = function(context){
var fn = this, args = [].slice.call(arguments, 1);
return function(){
return fn.apply( context, args.concat([].call(arguments)) );
};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment