Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
at(-1) vs slice(-1)[0] vs length - 1
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
at(-1)
14.9M/s
slice(-1)[0]
12.5M/s
length - 1
7.8M/s
View exact numbers
Test name
Executions per second
✓
at(-1)
14,908,409 Ops/sec
slice(-1)[0]
12,497,967 Ops/sec
length - 1
7,793,932 Ops/sec
Script Preparation code:
var array = Array({ length: 10000 }, (_, i) => i);
Tests:
at(-1)
array.at(-1);
length - 1
array[array.length - 1]
slice(-1)[0]
array.slice(-1)[0]