Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
03-31-2003, 05:53 AM #1
- Join Date
- Feb 2003
- Umeå, Sweden
- Thanked 83 Times in 74 Posts
var i=1; i+=i++ + ++i; // Gives i==5 // 1+(1 + 3)=5 // i 1 2 3
1. Lhs snapshot when i==1
2. Rhs eval of i++ gives 1, i==2
3. Rhs eval of ++i gives 3, i==3
4. Rhs eval of 1+3 gives 4, i==3
5. Eval of the assignment i+=4 from snapshot gives i==5.
This order is the same for the reverse:Code:
var j=10; j-=j-- - --j; // Gives j==8 // 10-(10 - 8)=8 // j 10 9 8
2. Rhs eval of j-- gives 10, j==9
3. Rhs eval of --j gives 8, j==8
4. Rhs eval of 10-8 gives 2, j==8
5. Eval of the assignment j-=2 from snapshot gives j==8.