+ 1
Why y equals 4 here instead of 3?
var x = 1 y = ++x + x alert(y) I assume "++x" changed the value of x first and thus by adding it to x (which is 'itself') the equation becomes like "y = 2 + 2", am I correct?
1 ответ
+ 4
Yes. Your reasoning is correct.
If you reverse the order then you will get 3.
y = x + ++x