| |
ActionScript Operator precedence
When two or more operators are used in a same expression , some operators take a precedence over other operators. The following table lists the operator precedence in ActionScript. Some rows in the table you may not think as operators. But they are used for altering the default precedence of the operator. For eg: parenthesis. Parenthesis raise the precedence of operators that are inside the parenthesis.
| Highest |
| () |
. |
|
|
| ++ |
-- |
~ |
! |
| * |
/ |
% |
|
| >> |
>>> |
<< |
|
| > |
>= |
< |
<= |
| == |
!= |
|
|
| & |
|
|
|
| ^ |
|
|
|
| | |
|
|
|
| && |
|
|
|
| || |
|
|
|
| = |
op= |
|
|
| Lowest |
As you can see from the table the parenthesis are having the highest precedence and the assignment operator is having the lowest precedence. That means always the operators inside the parenthesis will be executed first and the assignment operator will be executed the last. For eg:
10 * 2 + 2
evaluates to the value 22.
but if we are using parenthesis with this expression the result would change. For eg:
10 * (2+2)
evaluates to a value 40. Even though the + was having a lower precedence it evaluated first.
|
|