at(-1) vs length - 1 vs slice(-1)[0]Fastest: at(-1) (2.0x faster)
35,847,460 ops/sec
25,148,448 ops/sec
18,212,414 ops/sec
Results show median performance across all community submissions. Run this benchmark yourself to verify on your device.
| Test case name | Result |
|---|---|
| at(-1) | |
| length - 1 | |
| slice(-1)[0] |
| Test name | Executions per second |
|---|---|
| ✓ length - 1 | 113,645,376 Ops/sec |
| at(-1) | 97,301,496 Ops/sec |
| slice(-1)[0] | 39,207,348 Ops/sec |