Home > front end >  JavaScript arithmetic operators in the prefix or suffix or why suffix results not 121 and before the
JavaScript arithmetic operators in the prefix or suffix or why suffix results not 121 and before the

Time:04-26

Prefix or not to add and subtract in arithmetic? Suffix or not first operation in the add and subtract? Lost, I pray you to reassure

CodePudding user response:

Num1 initial 120,
The first expression to calculate num1 became 121
Num1 into 122, after second expression to calculate the value of the former num1 is 121, not 120
Num1 becomes 121, after the third expression to calculate the former num1 value is 122, not 120...

CodePudding user response:

Hello World, 1/f, reference response:
num1 initial 120,
The first expression to calculate num1 became 121
Num1 into 122, after second expression to calculate the value of the former num1 is 121, not 120
Num1 becomes 121, after the third expression to calculate the former num1 value is 122, not 120...

Why the first expression values into 121 results is 120

CodePudding user response:

Num1 + + is performed only after the statement change, so the output is 120, but the output (together) after it's already 121
  • Related