Standard built-ins

Array.prototype.at()

Try the free JavaScript compiler

Reads a relative index after integer conversion. Negative values count from the end; out-of-range indices return undefined. Does not mutate the source.

Formal Syntax & Structure

javascript syntaxjavascript
array.at(index)

Parameters & Attributes

NameTypeDescription
indexnumberRelative position, converted to an integer.

Return Value

any

Indexed value or undefined.

Working Example

Example Snippetjavascript
console.log([3,8].at(-1),[3,8].at(2));
JavaScript Reference