var a = 0; // a 0
b = (a = 3) + (a = 4);
// a = 3 ----> a为3,整个赋值语句返回3
// a = 4 ----> a为4,整个赋值语句返回4
// 由于返回值的内存和赋值操作用到的a的内存不同,所以b的运算所用的值,只和返回值有关,不受a的值变化的影响,因此,b = 3 + 4 = 7
// 所以,最终a为4,b为7
Assignment operations are combined from right to left. So the first thing is to assign (a=3)+(a=4) to b. However, (a=3)+(a=4) is executed from left to right. So it shows that 3 is assigned to a, and then 4 is assigned to a. So a ends up being 4 and b ends up being 7.
b=(a=3)+(a=4) This line of code is executed from left to right. When a=3 is executed, 3 is assigned to a. When a=4, 4 is assigned to a. The final value of a is 4.
Order of operations:
Assignment operations are combined from right to left. So the first thing is to assign (a=3)+(a=4) to b. However, (a=3)+(a=4) is executed from left to right. So it shows that 3 is assigned to a, and then 4 is assigned to a. So a ends up being 4 and b ends up being 7.
First execute a=3, then execute a=4, so in the end a is 4
a is assigned the value 4
b=(a=3)+(a=4) This line of code is executed from left to right. When a=3 is executed, 3 is assigned to a. When a=4, 4 is assigned to a. The final value of a is 4.