+ 1

What is the output of this code and how it comes?

var a=1; b=a; alert(-- a + b --);

27th Feb 2022, 3:40 AM
makhrab dip
2 Answers
+ 2
makhrab dip a = 1 So b would be 1 because b = a Now --a is pre-decrement so a would be 0 b-- is post decrement which first assign value so b-- would be 1 So finally 0 + 1 = 1
27th Feb 2022, 4:09 AM
AÍąJ
AÍąJ - avatar
+ 1
Both pre and post decrement should work for substract . Both a and b supposed to be 0 and result 0. Can anyone explain ?
7th Mar 2022, 7:23 AM
makhrab dip