Skip to content

Instantly share code, notes, and snippets.

@mindoftea
Last active August 29, 2015 14:01
Show Gist options
  • Save mindoftea/dffe4bae7f15d1b593ed to your computer and use it in GitHub Desktop.
Save mindoftea/dffe4bae7f15d1b593ed to your computer and use it in GitHub Desktop.
A demonstration of some of the power of closures when used for currying in JavaScript.
var f=function(x)
{
var g=function(y)
{
x*=y;
print(x);
return g;
};
return g;
};
f(2)(3)(5)(7)(11)(13)(17)(19);
// 6
// 30
// 210
// 2310
// 30030
// 510510
// 9699690
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment