
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Types of Values
|
45
Note the use of the inequality operator, !=, which determines whether two values are
not equal, and the quotes around “undefined”, because the typeof operator returns a
string. In Flash MX, we can alternatively use the strict inequality operator (
!= =)to
check if a value is not equal to
undefined or not of the type undefined.
if (someVariable != = undefined) {
// Any code placed here is executed only if someVariable is not undefined
}
Both the typeof and the strict inequality techniques just shown prevent Flash from
performing automatic datatype conversion when checking if someVariable is
undefined. By contrast, due to automatic datatype conversion, the regular inequality
operator (
!=) checks not only whether someVariable is undefined, but also whether it
contains the null value. For example:
if (someVariable != undefined) {
// Any code placed here is executed if someVariable is not undefined or null
}
The null value is often used by programmers to indicate that a variable is intention-
ally empty, but still exists.
Types of Values
The data we use in ActionScript programming comes in a variety of types. So far,
we’ve seen numbers and text, but other types include Booleans, arrays, functions,
and objects. Before we cover each datatype in detail, let’s examine some datatype ...