Skip to content

Instantly share code, notes, and snippets.

@kishanio
Created May 4, 2017 06:54
Show Gist options
  • Save kishanio/17995bfe9e000ab14e81ecfab48b838d to your computer and use it in GitHub Desktop.
Save kishanio/17995bfe9e000ab14e81ecfab48b838d to your computer and use it in GitHub Desktop.
JS Functional Programming : Currying Function
// Reference : https://www.sitepoint.com/currying-in-functional-javascript/
var greetCurried = function(greeting) {
return function(name) {
console.log(greeting + ", " + name);
};
};
var greetHello = greetCurried("Hello");
greetHello("Heidi"); // Hello, Heidi
greetHello("Eddie"); // Hello, Eddie
greetCurried("Hi there")("Howard"); // Hi there, Howard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment