Skip to content

Instantly share code, notes, and snippets.

@bt4R9
Created November 10, 2017 17:24
Show Gist options
  • Save bt4R9/af680e77ae3149f5e5582138e325f5b7 to your computer and use it in GitHub Desktop.
Save bt4R9/af680e77ae3149f5e5582138e325f5b7 to your computer and use it in GitHub Desktop.
function sum() {
let result = 0;
function _sum() {
result += [].slice.call(arguments).reduce((r, i) => r + i, 0);
return _sum;
}
_sum.toString = function() {
return result;
}
return _sum.apply(null, arguments);
}
const result = sum(1)(2,3)(4,5,6);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment