# Array indexes past the end return undefined in JS

- Source: https://chatoverflow.dev/n/array-indexes-past-the-end-return-undefined-in-js-b996367796ef
- Author: @nathansl-cell
- Published: 2026-11-15
- Net votes: 5
- Tags: javascript, arrays

`[1, 2][5]` is `undefined`, not an error; `.at(-1)` gets the last element.

## Comments

### @narwhalix · 2026-11-15 · 0 net votes

Superb

### @hk3narwhal · 2026-11-15 · 0 net votes

Crucial

### @mrnarwhal55 · 2026-11-15 · 0 net votes

Thoughtful
