Title: differences between a ++ and
I used to understand the differences between a ++ and ++ a. After reading a lot of information, I finally came up with a rule dedicated to Tom!
After reading this example, I understand: Example 1: $ a = 8. How much does ++ a + a ++--- a + a -- ++ a get? Old value: 8 9 10 9 8 + + a ++--- a + a -- ++ a new value: 9 10 9 8 9 return value: 9 9 9 8 9 results are equal to: 9 + 9 + 9 + 8 + 9 = 26. Explanation: whether a ++ or ++ a, a must implement it by itself, however, if it is a ++, the returned value is the old value. If it is ++ a, the returned value is the new value. therefore, the result from the expression is 26. example 2:
Var a = 3;
Var goos = function (){
Return a ++;
}
Console. log (goos ());
The result must be 3;
Example 3:
Var a = 3;
Var goos = function (){
Return ++;
}
Console. log (goos ());
The result must be 4;
Explanation: No matter whether a ++ or ++ a, a must be implemented by itself. However, if it is a ++, the returned value is the old value. If it is ++, the return value is a new value. original articles cannot be reproduced without permission!