Javascript: self-increasing PP/ self-subtracting-a small problem with the operator?

< H2 > on the MDN- operator precedence , the rear self-increment aPP has higher priority than the front self-increment PPa . What is the reason for this? < / H2 >

for example:

var a = 1;
var b = aPP;
//=> b = 1;

on the surface, it appears that PPa has a higher priority than = , while a muri- has a lower priority than = . What is the reason for this?

Mar.23,2021

Operator precedence in

javascript, which you can understand as combining precedence, javascript is always executed from left to right. The priority relationship between = and PP in the
assignment expression is not valid, and it will not be evaluated before = because of the high priority of PP , but before the combination. For the operation method of
= , please see 11.3.1

in ECMAScript 5.1.

b = PPa; can be understood as

var a = 1;
var b = fun();
function fun() {
    a = a + 1;
    return a;
}

and b = aPP; can be understood as

var a = 1;
var b = fun();
function fun() {
    var t = a;
    a = a + 1;
    return t;
}

you can refer to ECMAScript 5.1Specification (some rules are missing in Chinese version):
< del > Chinese version: http://www.ecma-international.

there is a description in Appendix D:

11.8.2, 11.8.3, and 11.8.5, the paraphrase EcmaScript is generally interpreted and executed from left to right, but the description language of the > and < = operators in the third edition of the specification results in a local right-to-left order. This specification has corrected these operators and is now interpreted in full order from left to right. However, this change to the order may be observed if there are side effects during the interpretation of the execution process.

all code in ECMAScript is executed from left to right (Evaluation order evaluation order), if you have side effects in your function, such as code in a problem, you can clearly observe "from left to right". For example, the question:
https://codeshelper.com/q/10.

operator priority and evaluation order are two different concepts. In sqrt (9) + sqrt (16) * sqrt (25) , the multiplication is wrong first, and the expression always runs from left to right, but it will be combined first when it encounters the * operator.

the execution process is similar to the following:

  1. sqrt (9)
  2. sqrt (16)
  3. sqrt (25)
  4. 4 * 5
  5. 3 + 20

the increment (PP)
increment operator increments its Operand by 1 and returns a numeric value.

if post (postfix) is used, that is, the operator is after the Operand (such as xPP), then the numeric value will be returned before increment.
if the prefix (prefix) is used, that is, the operator is in front of the Operand (such as PPx), then the value will be returned after increment.


PPa returns 2, so bread2
aPP returns 1, so bread1
has nothing to do with priority


actually there is no special meaning to pay attention to these. If you are not sure, add parentheses, while PP is only used in the monocular, and do not use too many tricks.


what others say is wrong
aPP+b will be recognized as (aPP) + b rather than a + (PPb)
Post self-increment has a higher priority than pre-self-increment, which is shown here

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2af15-2b2a3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2af15-2b2a3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?