Skip to content

Instantly share code, notes, and snippets.

@julien-f
Created November 15, 2018 12:33
Show Gist options
  • Save julien-f/5b7eb5e5cd95d176e474cecfb2e85155 to your computer and use it in GitHub Desktop.
Save julien-f/5b7eb5e5cd95d176e474cecfb2e85155 to your computer and use it in GitHub Desktop.
// 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