array[array.length - 1] vs array.at(-1)Fastest: array.at(-1) (1.8x faster)
31,635,868 ops/sec
17,517,538 ops/sec
Fastest: array[array.length - 1] (1.5x faster)
1,488,388,736 ops/sec
975,132,992 ops/sec
Fastest: array.at(-1) (1.5x faster)
24,567,316 ops/sec
16,793,016 ops/sec
Fastest: array.at(-1) (1.8x faster)
14,048,276 ops/sec
7,775,620 ops/sec
Fastest: array.at(-1) (1.6x faster)
25,918,340 ops/sec
15,826,887 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| array[array.length - 1] | |
| array.at(-1) |
| Test name | Executions per second |
|---|---|
| ✓ array[array.length - 1] | 168,821,616 Ops/sec |
| array.at(-1) | 164,110,704 Ops/sec |