Skip to content

Array Functions

Rohan Singh edited this page Aug 23, 2014 · 4 revisions

array values have the following functions defined.

Note: The functions that return array just return the value they acted on, not a new value. This enables calls to be chained like this: [].add(1).add(2).add(3)

add

add(item): array

Adds item to the end of the array.

clear

clear(): array

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): array

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): array

Removes the first occurrence of the item from the array.

removeAt

removeAt(index: number): array

Removes the item at the given index from the array.

length

length(): number

Returns the number of items in the array.

getEnumerator

getEnumerator(): object

Returns an enumerator for iterating over values in the array.

Clone this wiki locally