Skip to content

Instantly share code, notes, and snippets.

@xincici
Last active September 25, 2019 06:06
Show Gist options
  • Save xincici/f7f53fac28a0473fad3e to your computer and use it in GitHub Desktop.
Save xincici/f7f53fac28a0473fad3e to your computer and use it in GitHub Desktop.
add function
function add() {
let sum = 0;
Array.from(arguments).forEach(v => sum += v);
function f() {
Array.from(arguments).forEach(v => sum += v);
return f;
}
f.toString = f.valueOf = function() {
return +sum;
}
return f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment