+ 5

How come this output

var a = 3; var b = ++a; var c = a++; console.log(b, c, a);

1st Feb 2021, 8:14 PM
VṢtēphen
VṢtēphen - avatar
5 Réponses
+ 8
++a adds 1 to 'a' and returns, while a++ returns 'a' and then performs the addition on next cycle. So the output is like: 4 4 5
1st Feb 2021, 8:28 PM
Valen.H. ~
Valen.H. ~ - avatar
1st Feb 2021, 8:14 PM
VṢtēphen
VṢtēphen - avatar
+ 5
Thanks..
1st Feb 2021, 9:10 PM
VṢtēphen
VṢtēphen - avatar
+ 4
Thanks
2nd Feb 2021, 6:57 PM
VṢtēphen
VṢtēphen - avatar
+ 1
result is (b c a) =4 5 3
21st Mar 2021, 3:24 PM
vamsi krishna
vamsi krishna - avatar