User Guide

Data types 55
If you declare a variable, but do not declare its data type, the default data type * will apply,
which actually means that the variable is untyped. If you also do not initialize an untyped
variable with a value, its default value is
undefined.
For data types other than Boolean, Number, int, and uint, the default value of any
uninitialized variable is
null. This applies to all the classes defined by the Flash Player API, as
well as any custom classes that you create.
The value
null is not a valid value for variables of type Boolean, Number, int, or uint. If you
attempt to assign a value of
null to a such a variable, the value is converted to the default
value for that data type. For variables of type Object, you can assign a value of
null. If you
attempt to assign the value
undefined to a variable of type Object, the value is converted to
null.
For variables of type Number, there is a special top-level function named
isNaN() that returns
the Boolean value
true if the variable is not a number, and false otherwise.
Data types
A data type defines a set of values. For example, the Boolean data type is the set of exactly two
values:
true and false. In addition to the Boolean data type, ActionScript 3.0 defines several
more commonly used data types, such as String, Number, and Array. You can define your own
data types by using classes or interfaces to define a custom set of values. All values in
ActionScript 3.0, whether they are primitive or complex, are objects.
A primitive value is a value that belongs to one of the following data types: Boolean, int,
Number, String, and uint. Working with primitive values is usually faster than working with
complex values because ActionScript stores primitive values in a special way that makes
memory and speed optimizations possible.
A complex value is a value that is not a primitive value. Data types that define sets of complex
values include Array, Date, Error, Function, RegExp, XML, and XMLList.
NOTE
For readers interested in the technical details, ActionScript stores primitive values internally
as immutable objects. The fact that they are stored as immutable objects means that
passing by reference is effectively the same as passing by value. This cuts down on memory
usage and increases execution speed because references are usually significantly smaller
than the values themselves.