Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
JS array lastIndexOf vs indexOf
(version: 1)
JS array lastIndexOf vs indexOf
Comparing performance of:
Array.lastIndexOf vs Array.indexOf
Created:
3 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
var a = []; var i = 0; while (i <= 1E5) { i++; // Put the two results same disance from start and end if(i === 1E5 - 1E4 || i === 1E4) str.push("match") else a.push(i) }
Tests:
Array.lastIndexOf
const item = a.lastIndexOf("match");
Array.indexOf
const index = a.indexOf("match");
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Array.lastIndexOf
Array.indexOf
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0
Browser/OS:
Firefox 147 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array.lastIndexOf
188291.7 Ops/sec
Array.indexOf
128192.9 Ops/sec
Related benchmarks:
JS find vs indexOf with string
Some vs. findIndex 2
Some vs. findIndex 3
JS search vs indexOf
findIndex/indexOf
JS lastIndexOf vs indexOf
check index access speed
JS findIndex vs indexOf
JS find + indexOf vs findIndex
Comments
Confirm delete:
Do you really want to delete benchmark?