Skip to content

Instantly share code, notes, and snippets.

@nathan-lapinski
Created July 24, 2019 13:41
Show Gist options
  • Save nathan-lapinski/174494f8284a107654611cd2497beed5 to your computer and use it in GitHub Desktop.
Save nathan-lapinski/174494f8284a107654611cd2497beed5 to your computer and use it in GitHub Desktop.
a quick bind
function myBind(fn, context, ...args) {
return function(...moreArgs) {
return fn.call(context, ...(args.concat(moreArgs)));
}
}
// test
function add(a,b,c) {
return a + b + c;
}
console.log(myBind(add, null, 1,2)(3)) // 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment