To declare a new variable, we use the var
statement. For example:
var speed;
var bookTitle;
var x;
The word var tells the interpreter that
we're declaring a variable, and the text that follows, such as
speed, bookTitle, or
x, becomes our new variable's name. We can
create variables anywhere we can attach code: on a keyframe, a
button, or a movie clip.
We can also declare several variables with one
var statement, like this:
var x, y, z;
However, doing so impairs our ability to add comments next to each
variable.
Once a variable has been created, we may assign it a value, but
before we learn how to do that, let's consider some of the
subtler details of variable declaration.