You can't do this - how does the sum
function know whether you want it to return the answer or another function?
You could do something along these lines though:
sum(0)(1)(2)(3).result()
Implemented like this:
var sum = (function(){
var total = 0;
var f = function(n){
total += n;
return f;
};
f.result = function(){
return total;
};
return f;
}());