Skip to content

Instantly share code, notes, and snippets.

@AGhost-7
Last active May 23, 2017 03:28
Show Gist options
  • Select an option

  • Save AGhost-7/8151ea4bcc4bac234ed4 to your computer and use it in GitHub Desktop.

Select an option

Save AGhost-7/8151ea4bcc4bac234ed4 to your computer and use it in GitHub Desktop.
function add(a, b) {
if(arguments.length === 1) {
return add.bind(null, a);
} else {
return a + b;
}
}
var increment = add(1);
console.log(increment(10)); // 11
console.log(add(10, 10)); // 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment