Specifications
Example:
var m2 = mammals[2];
mammals[2] = "gorilla";
var thing = things[2][1]
The first statement retrieves the value of the third item of the mammals array and assigns it to
m2, which now contains "monkey". The second statement replaces the third item of the mammals
array with the value "gorilla". The third statement retrieves the second item of the third item's
array from the things array and assigns it to thing, which now contains "shrub".
As stated above, it is also possible to access the arrays using strings. These act as normal properties,
and can be accessed either using the square bracked operator ([]) or by directly dereferencing
the array object and specifying the property name (.name). These two accessor types can be
mixed freely as seen below with the address and phoneNumber properties.
var names = [];
names["first"] = "John";
names["last"] = "Doe";
var firstName = names["first"];
var lastName = names["last"];
names["address"] = "Somewhere street 2";
names.phoneNumber = "+0123456789";
var address = names.address;
var phoneNumber = names["phoneNumber"];
Array Properties
Holds the number of items in the array. Items with string keys
are excluded from the length property.
length : Number
Array Functions
Concatenates the array with one or more other arrays in the order
given and returns a single array.
var x = new Array( "a", "b", "c" );
concat( a1 : Array, a2 :
Array, ... aN : Array ) : Array
var y = x.concat( [ "d", "e" ], [ 90, 100 ] );
// y == [ "a", "b", "c", "d", "e", 90, 100 ]
Joins all the items of an array together, separated by commas or
by the specified optSeparator.
var x = new Array( "a", "b", "c" );
join( optSeparator : String )
: String
var y = x.join(); // y == "a,b,c"
var z = x.join( " * " ); // y == "a * b * c"
Pops (that is, removes) the top-most (right-most) item off the
array and returns it.
var x = new Array( "a", "b", "c" );
var y = x.pop(); // y == "c" x == [ "a", "b" ]
pop( ) : Object
Pushes (that is, inserts) the given items onto the top (right) end
of the array. The function returns the new length of the array.
var x = new Array( "a", "b", "c" );
x.push( 121 ); // x == [ "a", "b", "c", 121 ]
push( item1 : Object,
optItem2 : Object, ...
optItemN : Object )
372
Enfocus Switch 10