RIATest 2 Documentation Copyright © RIATest.com

Array Object

Array is an indexed list of objects.

Methods

MethodDescription

Array

new Array([item0[,item1[,...]]])
new Array(len)

Construct a new Array.

concat

concat([item1[,item2[,...]]])
Returns an array containing the array elements of this object followed by the array elements of each argument in order.

join

join(separator)
The elements of the array are converted to strings, and these strings are then concatenated, separated by occurrences of the separator. If no separator is provided, a single comma is used as the separator.

pop

pop()
The last element of the array is removed from the array and returned.

push

push([item1[,item2[,...]]])
The arguments are appended to the end of the array, in the order in which they appear. The new length of the array is returned as the result of the call.

reverse

reverse()
The elements of the array are rearranged so as to reverse their order. The object is returned as the result of the call.

shift

shift()
The first element of the array is removed from the array and returned.

slice

slice(start,end)
The slice method takes two arguments, start and end, and returns an array containing the elements of the array from element start up to, but not including, element end (or through the end of the array if end is undefined). If start is negative, it is treated as (length+start) where length is the length of the array. If end is negative, it is treated as (length+end) where length is the length of the array.

sort

sort(comparefn)
The elements of this array are sorted. The sort is not stable (that is, elements that compare equal do not necessarily remain in their original order). If comparefn is not undefined, it should be a function that accepts two arguments x and y and returns a negative value if x < y, zero if x = y, or a positive value if x > y.

splice

splice(start,deleteCount[,item1[,item2[,...]]])
When the splice method is called with two or more arguments start, deleteCount and (optionally) item1, item2, etc., the deleteCount elements of the array starting at array index start are replaced by the arguments item1, item2, etc. If start is negative, then it is treated as (length+start) where length is the length of the array. Function return array of deleted elements.

toString

toString()
Returns string representation of this object.

unshift

unshift([item1[,item2[,...]]])
The arguments are prepended to the start of the array, such that their order within the array is the same as the order in which they appear in the argument list. The new length of the array is returned as the result of the call.