Skip to content

Instantly share code, notes, and snippets.

@skounis
Created February 6, 2019 11:51
Show Gist options
  • Save skounis/5407e3954b4d7c9b1761b4fec73a9e2b to your computer and use it in GitHub Desktop.
Save skounis/5407e3954b4d7c9b1761b4fec73a9e2b to your computer and use it in GitHub Desktop.
A dead simple Closure example in Javascript
const partialApply = (fn, ...fixedArgs) => {
return function (...remainingArgs) {
return fn.apply(this, fixedArgs.concat(remainingArgs));
};
}
const add = (a, b) => a + b;
const add10 = partialApply(add, 10);
add10(5) // 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment