Skip to main content

API Reference

Classes

Array

Immutable Array.

Methods

NameDescription
at
Get the value at the given index.
concat
Merge arr to the end of this array.
contains
Checks if this array includes searchElement.
copyMut
Create a mutable shallow copy of this array.
indexOf
Returns the index of the first occurrence of searchElement found.
join
Returns a new string containing the concatenated values in this array, separated by commas or a specified separator string.
lastIndexOf
Returns the index of the last occurrence of searchElement found.
slice
Returns a shallow copy of a portion of the array.
tryAt
Get the value at the given index, returning nil if the index is out of bounds.

at
at(index: num): <T>

Get the value at the given index.

indexRequired
  • Type: num

index of the value to get.


concat
concat(arr: Array): Array

Merge arr to the end of this array.

arrRequired

array to merge.


contains
contains(searchElement: <T>): bool

Checks if this array includes searchElement.

searchElementRequired

to search for.


copyMut
copyMut(): MutArray

Create a mutable shallow copy of this array.

indexOf
indexOf(searchElement: <T>): num

Returns the index of the first occurrence of searchElement found.

searchElementRequired

to search for.


join
join(separator?: str): str

Returns a new string containing the concatenated values in this array, separated by commas or a specified separator string.

If the array has only one item, then that item will be returned without using the separator.

separatorOptional
  • Type: str

lastIndexOf
lastIndexOf(searchElement: <T>): num

Returns the index of the last occurrence of searchElement found.

searchElementRequired

to search for.


slice
slice(start?: num, end?: num): Array

Returns a shallow copy of a portion of the array.

startOptional
  • Type: num

the beginning index of the slice, inclusive.


endOptional
  • Type: num

the ending index of the slice, exclusive.


tryAt
tryAt(index: num): <T>?

Get the value at the given index, returning nil if the index is out of bounds.

indexRequired
  • Type: num

index of the value to get.


Properties

NameTypeDescription
length
numThe length of the array.

lengthRequired
length: num;
  • Type: num

The length of the array.


MutArray

Mutable Array.

Methods

NameDescription
at
Get the value at the given index.
clear
Removes all elements.
concat
Merge arr to the end of this array.
contains
Checks if this array includes searchElement.
copy
Create an immutable shallow copy of this array.
indexOf
Returns the index of the first occurrence of searchElement found.
insert
Inserts a new value at the given index of an array.
join
Returns a new string containing the concatenated values in this array, separated by commas or a specified separator string.
lastIndexOf
Returns the index of the last occurrence of searchElement found.
pop
Remove value from end of array.
popAt
Removes value from the given index of an array.
push
Add values to end of array.
removeFirst
Removes first occurrence of a given value in an array.
set
Sets a new value at the given index of an array.
slice
Returns a shallow copy of a portion of the array.

at
at(index: num): <T>

Get the value at the given index.

indexRequired
  • Type: num

index of the value to get.


clear
clear(): void

Removes all elements.

concat
concat(arr: MutArray): MutArray

Merge arr to the end of this array.

arrRequired

array to merge.


contains
contains(searchElement: <T>): bool

Checks if this array includes searchElement.

searchElementRequired

to search for.


copy
copy(): Array

Create an immutable shallow copy of this array.

indexOf
indexOf(searchElement: <T>): num

Returns the index of the first occurrence of searchElement found.

searchElementRequired

to search for.


insert
insert(index: num, value: <T>): void

Inserts a new value at the given index of an array.

indexRequired
  • Type: num

the index to insert the value at.


valueRequired

the value to insert at the given index.


join
join(separator?: str): str

Returns a new string containing the concatenated values in this array, separated by commas or a specified separator string.

If the array has only one item, then that item will be returned without using the separator.

separatorOptional
  • Type: str

lastIndexOf
lastIndexOf(searchElement: <T>): num

Returns the index of the last occurrence of searchElement found.

searchElementRequired

to search for.


pop
pop(): <T>

Remove value from end of array.

popAt
popAt(index: num): <T>

Removes value from the given index of an array.

indexRequired
  • Type: num

the index to remove the value at.


push
push(...values: Array<<T>>): void

Add values to end of array.

valuesRequired

values to add.


removeFirst
removeFirst(value: <T>): bool

Removes first occurrence of a given value in an array.

valueRequired

the value to remove.


set
set(index: num, value: <T>): void

Sets a new value at the given index of an array.

indexRequired
  • Type: num

the index to set the value at.


valueRequired

the value to set at the given index.


slice
slice(start?: num, end?: num): MutArray

Returns a shallow copy of a portion of the array.

startOptional
  • Type: num

the beginning index of the slice, inclusive.


endOptional
  • Type: num

the ending index of the slice, exclusive.


Properties

NameTypeDescription
length
numThe length of the array.

lengthRequired
length: num;
  • Type: num

The length of the array.