Benchmarking ways to grab the last element of an array
const arr = Array.from({ length: 1_000_000 }, (_, i) => i);Initializing...
| Test Case | Ops/sec | |
|---|---|---|
| In-place reverse + rest destructuring | | ready |
| Slice to one-element array | | ready |
| Direct indexing | | ready |
| Negative index with at() | | ready |
| Slice last element | | ready |
| Slice copy + pop | | ready |
| Spread copy + pop | | ready |
| Spread copy + reverse | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.