at()

Get the Array element at a given index.

Signature

at(index: Int): Any

Description

The at() method gets the Array element located at index. The method is equivalent to using [] indexing, such that array.at(0) returns the same element as array[0].

Arrays have zero-based indexes, so valid values for index range from zero to one less than the Array length. Invalid index values result in an error.

Parameters

Parameter Type Required Description

index

Int

Yes

Location of the Array element to return. Valid index values range from zero to one less than the Array length.

Return value

Type Description

Any

Array element located at index.

Examples

Get the element at index location four:

[1, 2, 3, 4, 5].at(4)
5

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!