Created
November 10, 2017 17:24
-
-
Save bt4R9/af680e77ae3149f5e5582138e325f5b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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