
Array Class
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
443
the correct type is left as an exercise to the reader. (Hint: see the typeof operator.) Here’s
the code:
function someFunction (y, z) {
if (arguments.length != 2) {
trace("Function invoked with wrong number of parameters");
return;
}
// Proceed with normal function body...
}
Array Class
support for ordered lists of data
Flash 5; sortOn() method added in Flash 6
Constructor
new Array()
new Array(len)
new Array(element0, element1, element2,...elementn)
Arguments
len A nonnegative integer specifying the size of the new array.
element0, ...element
n
A list of one or more initial values to be assigned as elements of the array.
Properties
length The number of elements in an array (including empty elements).
Methods
concat() Create a new array by appending additional elements to an existing array.
join() Convert the elements of an array to strings, and concatenate using a customi-
zable delimiter.
pop() Remove and return the last element of an array.
push() Add one or more elements to the end of an array.
reverse() Reverse the order of elements in an array.
shift() Remove and return the first element of an array.
slice() Create a new array using a subset of elements from an existing array.
sort() Sort the elements of an array according to the specified rule. ...