Always to self-increment and self-reduction of the order of execution a little confused, today checked the information, to summarize
a++ (a--), that is, calculate a, the next time you use this variable to execute + + or--
++a (--a) refers to the calculation of + + or--
Example 1:
var c = 1;
var B = (c + +) +c;
alert (b);//3
At this point, C + + is calculated first, because there is also a C in the expression, so at this point (for the time being C + + as a whole) a = 1, then c immediately increases by 1 is a=2, then calculates the second c=1,
Then assign the value 3 of the a+c to B
Example 2:
var c = 1;
var B = (++c) + (++C);
alert (b);//5
At this point, the ++c=2 is computed first, so the second c=2, then the second C is ++c=3, and then the value 5 of the 2+3 is assigned to B.
Example 3:
var c = 1;
var B = (c + +) +3;
alert (b);//4
At this point, the display calculates C + + with a value of 1 and then performs a 1+3=4 assignment to B, since no c is used for the second time, so the answer is 4 instead of 5;
Example 4:
var c = 1;
var B = (c + +) + (c + +);
alert (b);//3
alert (c);//3
At this point, C + + is calculated first, because there is also a C in the expression, when the second C is computed, the first C increment 1 becomes 2, so the final answer is 2+1=3, not 4.
But when alert (c) was used, C was once, so C again increased by 1 to get 3.
Self-increment and self-subtraction in JavaScript