0

function abc(a){ return(function(y){ return y+1; }) (++a)+a; } alert(abc(2));

//output= 7 //do u have any explanation?

21st Jun 2017, 9:54 PM
islam moheb
islam moheb - avatar
2 odpowiedzi
+ 11
You put an argument a as 2. a gets pre-incremented by one and so now equals 3. You add up 3+3 and get 6. But you asked the function to return the result plus one (return y+1) and so you receive 7 in the end.
21st Jun 2017, 10:41 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
0
Try formatting the code in the description
21st Jun 2017, 9:59 PM
Limitless
Limitless - avatar