Created
March 2, 2014 22:15
-
-
Save peterpme/9314807 to your computer and use it in GitHub Desktop.
Javascript: Currying Example
This file contains hidden or 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
//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