Anybody tell me what will be this output. var a = 5; var b = ++a; var c = b++; alert(a+b+c); Also tell how.PLEASE. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Anybody tell me what will be this output. var a = 5; var b = ++a; var c = b++; alert(a+b+c); Also tell how.PLEASE.

I can't understand how to calculate it.

11th Jul 2020, 12:24 PM
Tahsin Ahmed
Tahsin Ahmed - avatar
3 Answers
+ 5
a = 5, b = ++a //b= 6 and a = 6 c = b++ // c = 6 and b= 7 Therefore a+b+c = 6+7+6 = 19
11th Jul 2020, 12:30 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 3
Thanks a lot
11th Jul 2020, 1:23 PM
Tahsin Ahmed
Tahsin Ahmed - avatar
+ 2
var a=5 var b=++5 which is pre increment happening here So, var b=6 var c=b++ which is post increment happening here ,so var c=6 ,b is is incremented to 7 now So 5+7+6
11th Jul 2020, 12:27 PM
Abhay
Abhay - avatar