Skip to content

Instantly share code, notes, and snippets.

@Mizzlr
Created June 16, 2016 08:44
Show Gist options
  • Save Mizzlr/89bbca9f69fbb6201302c7c872e93c1c to your computer and use it in GitHub Desktop.
Save Mizzlr/89bbca9f69fbb6201302c7c872e93c1c to your computer and use it in GitHub Desktop.
var f1 = function(a,b){
// do something with a and b
return a + b;
};
var f2 = function(a){
// can do something with a here
return function(b){
// can do something with a and b here
return a + b;
};
};
// calling them f1 and f2
var c = f1(10,5);
var d = f2(10)(5);
// can also do
var f3 = f2(10);
// f3 is a function that adds 10
// to anything that is input
var e = f3(5); // add 5 to 10
// they are the same except the syntax changes
assert(c == d && d == e);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment