On this page
  1. Array.at
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

Array.at

Prev: some | Up: Array | Next: toSorted
Rel: Array, Array & Typed Arrays Guide
Ref: MDN Web Docs — Array.at
Tags: #public #web #javascript #builtins #array #tier/core


Signature & Overview

arr.at(index)

Returns the element at index, supporting negative indexing from the end (arr.at(-1)).

Notes & Pitfalls

Example

const items = ["first", "middle", "last"];
console.assert(items.at(0) === "first");
console.assert(items.at(-1) === "last");
console.assert(items.at(99) === undefined);

Linked from

Related notes