Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
at method versus array index
How does Array.prototype.at() performance compare to traditional indexing (arr[i]).
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0
Browser:
Firefox 137
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Initial value indexing
459557.7 Ops/sec
Random value indexing
440218.0 Ops/sec
Last value indexing
245015.4 Ops/sec
Initial value at()
89233.0 Ops/sec
Random value at()
95650.5 Ops/sec
Last value at()
81549.8 Ops/sec
Script Preparation code:
arr = Array.from({length: 1000}, (_, i) => i);
Tests:
Initial value indexing
const index_zero = arr[0]; console.log(index_zero);
Random value indexing
const index_random = arr[Math.floor(Math.random() * arr.length)]; console.log(index_random);
Last value indexing
const index_last = arr[arr.length - 1]; console.log(index_last);
Initial value at()
const at_zero = arr.at(0); console.log(at_zero);
Random value at()
const at_random = arr.at(Math.floor(Math.random() * arr.length)); console.log(at_random);
Last value at()
const at_last = arr.at(-1); console.log(at_last);