Skip to content

Array Functions

Rohan Singh edited this page Jun 13, 2017 · 4 revisions

array values have the following functions defined.

add

add(item)

Adds item to the end of the array.

clear

clear()

Removes all items from the array.

contains

contains(item): bool

Returns true if the array contains item.

indexOf

indexOf(item): number

Returns the index of the first occurrence of the item in the array, or -1 if it was not found.

insert

insert(index: number, item)

Inserts the item into the array at the given index.

lastIndexOf

lastIndexOf(item): number

Returns the index of the last occurrence of the item in the array, or -1 if it was not found.

remove

remove(item): bool

Removes the first occurrence of the item from the array. Returns true if an item was removed.

removeAt

removeAt(index: number)

Removes the item at the given index from the array.

sort

sort()

sort(index: number, count: number)

In-place sorts the contents of the array in ascending order.

sortDescending

sortDescending()

sortDescending(index: number, count: number)

In-place sorts the contents of the array in descending order.

length

length(): number

Returns the number of items in the array.

getEnumerator

getEnumerator(): object

Returns an enumerator for iterating over values in the array.