Skip to content

Instantly share code, notes, and snippets.

@alenaksu
Created June 19, 2018 10:40
Show Gist options
  • Save alenaksu/f447546486bd7608a917235d341c7e36 to your computer and use it in GitHub Desktop.
Save alenaksu/f447546486bd7608a917235d341c7e36 to your computer and use it in GitHub Desktop.
js currying
function curry(fn) {
function nest(...args) {
const next = this.bind(this, ...args);
if (args.length === 0 || next.length === 0) {
return next();
} else {
return nest.bind(next);
}
}
return nest.bind(fn);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment