Array
The Array object is used to store multiple values in a single variable. Array indexes are zero-based: The first element in the array is 0, the second is 1, and so on.
- concatArray
- concatenates (joins) two arrays.
- contains
- returns a boolean value indicating whether a node is a descendant of a specified node
- copywithinArray
- method copies array elements to another position in the array. overwrites the existing values and does not add items to the array.
- fillArray
- method fills specified elements in an array with a value. overwrites the original array. Start and end position can be specified. If not, all elements will be filled.
- indexOf
- searches an array for a specified item and returns its position
- join
- returns an array as a string
- lastindexofArray
- method returns the last index (position) of a specified value. starts at a specified index and searches from right to left. By default the search starts at the last element and ends at the first. Negative start values counts from the last element (but still searches from right to left).
- push
- adds new item to the end of an array
- remove
- removes an element from an array
- reverseArray
- method reverses the order of the elements in an array.
- sortArray
- basic sort method sorts the elements of an array. sorts the elements as strings in alphabetical and ascending order.
- splice
- adds and/or removes array elements
examples
function TestArray()
{
var row = ["1", "two"];
if (row.contains("two"))
{
row.push("3"); // adds to the back
row.remove("1"); // removes first
echo(row.indexOf("two")); // returns 0
}
}
- concatArray
- concatenates (joins) two arrays.
- contains
- returns a boolean value indicating whether a node is a descendant of a specified node
- copywithinArray
- method copies array elements to another position in the array. overwrites the existing values and does not add items to the array.
- fillArray
- method fills specified elements in an array with a value. overwrites the original array. Start and end position can be specified. If not, all elements will be filled.
- indexOf
- searches an array for a specified item and returns its position
- join
- returns an array as a string
- lastindexofArray
- method returns the last index (position) of a specified value. starts at a specified index and searches from right to left. By default the search starts at the last element and ends at the first. Negative start values counts from the last element (but still searches from right to left).
- push
- adds new item to the end of an array
- remove
- removes an element from an array
- reverseArray
- method reverses the order of the elements in an array.
- sortArray
- basic sort method sorts the elements of an array. sorts the elements as strings in alphabetical and ascending order.
- splice
- adds and/or removes array elements
check each function description for extended examples.