Last active
September 15, 2017 04:23
-
-
Save garrettmac/fc70be7b12b63f27e4eca519cb027d5f to your computer and use it in GitHub Desktop.
MEDIUM BLOG POST - Javascript’s 3 Major Paradigms: The Five tenets of Functional Programming [part 3 of 4]
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(a, b) { | |
return a + b; | |
} | |
add(3, 4);//returns 7 | |
//This is a function that takes two arguments, a and b, and returns their sum. We will now curry this function: | |
function add(a) { | |
return function (b) { | |
return a + b; | |
} | |
} | |
//This is a function that takes one argument, a, and returns a function that takes another argument, b, and that function returns their sum. | |
add(3)(4); | |
var add3 = add(3); | |
add3(4); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment