Created
November 15, 2018 12:33
-
-
Save julien-f/5b7eb5e5cd95d176e474cecfb2e85155 to your computer and use it in GitHub Desktop.
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
// create a bound function which receive itself injected as first arg | |
function rbind(fn, thisArg, ...args) { | |
function bound() { | |
return fn.apply( | |
thisArg === undefined ? this : thisArg, | |
args.concat(arguments) | |
); | |
} | |
args.unshift(bound); | |
return bound; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment