Understanding the ActionScript Language > Using operators to manipulate values in expressions > Operator precedence |  |

Operator precedence

When two or more operators are used in the same statement, some operators take precedence over others. ActionScript follows a precise hierarchy to determine which operators to execute first. For example, multiplication is always performed before addition; however, items in parentheses take precedence over multiplication. So, without parentheses, ActionScript performs the multiplication in the following example first:

    total = 2 + 4 * 3;

The result is 14.

But when parentheses surround the addition operation, ActionScript performs the addition first:

    total = (2 + 4) * 3;

The result is 18.

For a table of all operators and their precedence, see Operator Precedence and Associativity.