
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
111
Chapter 5
CHAPTER 5
Operators
An operator is a symbol or keyword that manipulates, combines, or transforms data. If
you’re new to programming, you’ll notice that some mathematical operators, such as
+ (addition) and – (subtraction), are very familiar. In other cases, you’ll have to learn
special programming syntax, even if the concepts are familiar. For example, to multi-
ply two numbers, ActionScript uses the symbol * (the multiplication operator) instead
of the × typically taught in grade school. For example, this multiplies 5 times 6:
5 * 6;
General Features of Operators
Though each operator has its own specialized task, all operators share a number of
general characteristics. Before we consider the operators individually, let’s see how
they behave generally.
Operators and Expressions
Operators perform actions using the data values (operands) supplied. For example, in
the operation
5 * 6, the numbers 5 and 6 are the operands of the multiplication oper-
ator (*). The operands can be any kind of expression; for example:
total = player1score + bonusScore; // Operands are variables
answer = (x+y) - (Math.PI * radius * radius); // Operands are complex expressions
Observe in the second example that both the left and right operands of the – opera-
tor are expressions that themselves involve ...