JavaScript does not allow a reverse type of assignment structure. This means that you cannot have an assignment to an expression:
6 + 8 = result; [Not allowed]
Nor can you have an assignment to a variable in this manner:
5 = MyValue; [Not allowed]
This is an arithmetic operator.
What This Means...some more details.
What this means is that variable identifiers must be on the left side of the JavaScript assignment:
result = 6 + 8; [OK] MyValue = 5; [OK]
Because variable identifiers must be on the left side of the assignment statement, they are referred to as L values (for Left).
Details, details, details...
Precedence of Operations...some more details.
Precedence of operations is simply the order in which arithmetic operations are preformed. As an example, consider the following assignment statement:
x = 5 + 4/2;
Precedence of operations requires that division be done before addition.
If there were not rules for precedence of operators, then there could be two separate answers for the assignment: x = 5 + 4/2; For example, if the division is preformed first: x = 5 + 2 = 7. If the addition is preformed first: x = 9/2 = 4.5. It is for this reason JavaScript needs rules to know how to get predictable and consistent results. The table below shows the precedence of operations for arithmetic computations in JavaScript.
Priority
Operation
First Second Third Fourth
( ) parenthesis - negation, assigning a negative number. Multiplication and Division Addition and Subtraction Note: In all cases operations go from left to right.