Created
January 15, 2015 15:15
-
-
Save jwoudenberg/47cb678ae735e32813f6 to your computer and use it in GitHub Desktop.
How to use .bind to pre-apply arguments.
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 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