Skip to content

Instantly share code, notes, and snippets.

@cowboy
Last active June 20, 2018 19:59
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cowboy/5373000 to your computer and use it in GitHub Desktop.
Save cowboy/5373000 to your computer and use it in GitHub Desktop.
JavaScript: Function.prototype.unbind (for @jugglinmike)
Function.prototype.bind = (function(origBind) {
return function() {
var fn = origBind.apply(this, arguments);
fn.__origFn__ = this.__origFn__ || this;
return fn;
};
}(Function.prototype.bind));
Function.prototype.unbind = function() {
return this.__origFn__;
};
@michacom
Copy link

thanks for cool pattern to extend a function:

    var f = (function (origF) { /* blah-blah-blah; */ origF(); }) (f);

@modestemax
Copy link

cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment