Standard built-ins
Array.prototype.at()
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
| Name | Type | Description |
|---|---|---|
| index | number | Relative 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));