Skip to content

Instantly share code, notes, and snippets.

@jwoudenberg
Created January 15, 2015 15:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwoudenberg/47cb678ae735e32813f6 to your computer and use it in GitHub Desktop.
Save jwoudenberg/47cb678ae735e32813f6 to your computer and use it in GitHub Desktop.
How to use .bind to pre-apply arguments.
function add(num1, num2) {
return num1 + num2;
}
var addFive = add.bind(null, 5);
var sum = addFive(3);
console.log(sum); //-> 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment