Last active
June 20, 2018 19:59
-
-
Save cowboy/5373000 to your computer and use it in GitHub Desktop.
JavaScript: Function.prototype.unbind (for @jugglinmike)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for cool pattern to extend a function: