Skip to content

Instantly share code, notes, and snippets.

@peterpme
Created March 2, 2014 22: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 peterpme/9314807 to your computer and use it in GitHub Desktop.
Save peterpme/9314807 to your computer and use it in GitHub Desktop.
Javascript: Currying Example
//Javascript Currying
function boxes(a){
return function(b) {
return "I like " + a + " " + b;
};
}
var myboxes = boxes("my boxes");
var yourboxes = boxes("your boxes");
console.log("my boxes:");
var red = myboxes("red");
// i like my boxes red
console.log(red);
console.log("your boxes:");
var blue = yourboxes("blue");
// i like your boxes blue
console.log(blue);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment