Skip to content

Instantly share code, notes, and snippets.

@armoucar
Created February 21, 2012 14:22
Show Gist options
  • Save armoucar/1876768 to your computer and use it in GitHub Desktop.
Save armoucar/1876768 to your computer and use it in GitHub Desktop.
js currying
/***
currying
***/
function add(x, y) {
var oldx = x, oldy = y;
if (typeof oldy === "undefined") { // partial
return function (newy) {
return oldx + newy;
}
}
return x + y;
}
typeof add(5); // "function"
add(3)(4); // 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment