Or am I confusing questions?
You. I think itβs much easier to think about priority as a grouping than about ordering. It affects the evaluation order, but only because it changes the grouping.
I definitely don't know about Javascript, but in Java operands are always evaluated in order from left to right. The fact that == has higher priority than || , means that
true || foo == getValue()
estimated as
true || (foo == getValue())
but not
(true || foo) == getValue()
If you just think of priority in this way, and then think that evaluation is always left to right (therefore, the left operand || always evaluated to the right operand, for example), then everything is simple - and getValue() never evaluated due to a short circuit.
To eliminate a short circuit from an equation, consider this example instead:
A + B * C
... where A , B and C can be just variables or can be other expressions, such as method calls. In Java, this is guaranteed to be evaluated as:
- Rate
A (and remember it later) - Rate
B - Rate
C - Multiply the score of
B and C - Add the result of the score
A with the result of the multiplication
Note that although * has a higher priority than + , A is still rated to B or C If you want to think about priority in terms of ordering, pay attention to how multiplication still happens before adding, but it still does the evaluation order from left to right.
source share