Skip to content

Instantly share code, notes, and snippets.

@cdleary
Created August 11, 2011 06:18
Show Gist options
  • Save cdleary/1139011 to your computer and use it in GitHub Desktop.
Save cdleary/1139011 to your computer and use it in GitHub Desktop.
Rebinding proposal for JS
Function.prototype.bind = function(thisVal) {
var func = this.__orig__ || this;
var bound = function() {
return func.apply(thisVal, arguments);
};
bound.__orig__ = func;
return bound;
};
var f = function() { return this; }
print(f.bind(12)());
print(f.bind(12).bind(13)())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment