+ 3
Why single variable increment and decrement not supporting in one statement?
Ex print(--5++)
2 ответов
+ 2
you can still use
var a = 5;
alert (--a);
a++
0
print (--5++)
returns 4
this is because ++x and --x in-/de- crements the number, before returning it. example:
x=5
print (--x) would output 4
on the other hand x++ and x-- in-/de- crements after returning the number. Therefore x=5
print (x++) outputs 5 then increments so if you then do print (x) it now outputs 6
so
x=5
print (--x++) = 4
print(x) = 5