function sum var result console log first log result return function r

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
function sum(a){
var result = a;
console.log('first log '+result);
return function(b){
result += b;
console.log('second log '+result);
};
console.log('final log '+result);
alert(result);
}
sum(1)(2);