As user codebox already said: This is not possible.
What you can do instead is to take the current parameter of the function into account. If there is no parameter you can return the result:
sum(1)(2)() == 3
Here is the implementation:
var sum = (function() {
var total = 0;
return function add(a) {
if(a === undefined) {
return total;
}
total += a;
return add;
};
}());