Help

JS-ARRAY

JavaScript supports two kinds of arrays. Associative and numerical arrays. Numerical arrays are represented by the JavaScript Array "class". Arcane Ages's JavaScript supports the following standard JavaScript Array properties:

length             This is the length of the array.  This value is
                   automatically updated.  This value is not just
                   read-only.  You can set it to a value to truncate
                   the size of array to be something smaller.  In
                   fact, an easy trick to empty an entire array is to
                   do:  "myArray.length = 0;"

Arcane Ages's JavaScript also supports the following standard Array methods:

concat( args )     This returns a new Array which contains of a copy
                   of this array plus all the arguments passed to this
                   method concatenated to the end of it.
clone()            This returns a new copy of this array.
join( sep )        This returns a string consisting of all of the elements
                   separated by the "sep" string.  If no "sep" string is
                   specified a value of "," will be used.
reverse( sep )     This method reverses the elements in the array.  For
                   example the array "a, b, c, d" would become
                   "d, c, b, a".
pop()              This method removes and returns the element at the end
                   of this array.  If the array was already empty, this
                   method returns undefined.
push( args )       This method adds all the arguments passed to this method
                   to the end of the array.  The new length of the array
                   is then returned by this function.
shift()            Like pop() except that this removes and returns the
                   element at the beginning of the array.
slice( b [, e ] )  This returns a subset of the array starting with
                   position b and ending at position e-1.  If e is not
                   specified then e is assumed to be equal to the array
                   length.  Both b and e can also be negative numbers,
                   indicating that they start from the end of the array
                   rather than the beginning.  For example,
                   "arr.slice( -2 )" will return the last two elements
                   of the array.
splice()           See JS-ARRAY-SPLICE for more information.
sort( sortFunc )   This method sorts the array according to the passed
                   in sort function.  See JS-ARRAY-SORT.
unshift( args )    Like push() except that this inserts the arguments
                   at the beginning of the array.

Arcane Ages's JavaScript also supports the following Array extensions:

clear()            This empties the array.  "arr.clear()" is equivalent to
                   "arr.length = 0;"
compact()          This compacts the array, eliminating empty slots.
                   The number of slots saved is returned.
has()              This returns true if the specified element is in the
                   array.  This method supports cardinalities -- see
                   JS-CARDINALITY.
random()           This returns a random element from the array.  The
                   array itself is not modified.
subtract( args )   All elements that equal any of the args are removed
                   from the array.  The number of slots saved is returned.
visit( f )         Applies the passed in function to all of the elements
                   in the array.  See JS-VISIT for more information.
unique()           This works like compact() except that duplicate values
                   are also removed.
union( args )      This works like push() except that args are only added
                   if they aren't already in the array.  The number
                   of slots added is returned.

See JS-ARRAY-EXAMPLES for examples on how to use numerical arrays.