Array.at

Array.at

Array.at

Function

Read array elements by subscript, and support negative numbers in reverse reading from the end of the array.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
indexIntNo0Element index; negative numbers count backwards from the end.

Return value

TypeDescription
Any/EmptyThe corresponding element is returned when the subscript is valid, and Empty is returned when it is out of bounds.

Example

Notes

  • at does not modify the original array.
  • when reading the last element, at(-1) requires one less array allocation than slice(-1)[0].