Skip to content

Instantly share code, notes, and snippets.

@garrettmac
Last active September 15, 2017 04:23
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 garrettmac/fc70be7b12b63f27e4eca519cb027d5f to your computer and use it in GitHub Desktop.
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]
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