MACROMEDIA FLEX-FLEX ACTIONSCRIPT LANGUAGE Reference page 32

Actionscript language reference
Table of Contents

Advertisement

Operator precedence and associativity
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.
When two or more operators share the same precedence, their associativity determines the order
in which they are performed. Associativity can be either left-to-right or right-to-left. For example,
the multiplication (*) operator has an associativity of left-to-right; therefore, the following two
statements are equivalent:
total = 2 * 3 * 4;
total = (2 * 3) * 4;
The following table lists all the ActionScript operators and their associativity, from highest to
lowest precedence.
Operator
x++
x--
.
[ ]
( )
function ( )
++x
--x
-
~
!
new
delete
typeof
void
32
Chapter 1: ActionScript Basics
Description
Highest precedence
Post-increment
Post-decrement
Object property access
Array element
Parentheses
Function call
Pre-increment
Pre-decrement
Unary negation, such as x = -1
Bitwise NOT
Logical NOT
Allocate object
Deallocate object
Type of object
Returns undefined value
Associativity
Left to right
Left to right
Left to right
Left to right
Left to right
Left to right
Right to left
Right to left
Left to right
Right to left
Right to left
Right to left
Right to left
Right to left
Right to left

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents