Created
April 25, 2015 14:46
-
-
Save icecreamliker/8b2657a12a86ffec3421 to your computer and use it in GitHub Desktop.
invokable function
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 calc(x) { | |
var _sum = x; | |
var fn = function(y) { | |
_sum += y; | |
return arguments.callee; | |
} | |
fn.toString = function() { | |
return _sum; | |
} | |
return fn; | |
} | |
calc(1); | |
calc(1)(2)(3)(4); // 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment