Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
includes vs in vs indexOf
(version: 0)
Comparing performance of:
indexOf vs in vs includes
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var codes = []; var usedCodes = []; for(i=0; i<10000; i++){ codes.push(i); if (i % 2) usedCodes.push(i); }
Tests:
indexOf
codes.forEach(x => { if (usedCodes.indexOf(x) > -1) { } });
in
codes.forEach(x => { if (x in usedCodes) { } });
includes
codes.forEach(x => { if (usedCodes.includes(x)) { } });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
indexOf
in
includes
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Array.includes() vs Array.indexOf()
IndexOf vs Includes array of numbers
Array find with indexOf vs includes
set.has vs. array.includes (1 million entries)
array.includes vs array.indexOf
Comments
Confirm delete:
Do you really want to delete benchmark?