Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Some vs. Filter vs. indexOf vs. includes (string version)
(version: 0)
Comparing performance of:
Array.some vs Array.filter vs Array.indexOf vs Array.includes
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var hasZero = []; var withoutZero = []; for (var i = 0; i < 10000; i++) { hasZero.push(Math.floor(Math.random() * 1000) + "_test"); withoutZero.push((Math.floor(Math.random() * 1000) + 1) + "_test") }
Tests:
Array.some
var tempResult = !!Math.round(Math.random()) ? hasZero.some(v => v === 0) : withoutZero.some(v => v === 0);
Array.filter
var tempResult = !!Math.round(Math.random()) ? hasZero.filter(v => v === 0) : withoutZero.filter(v => v === 0);
Array.indexOf
var tempResult = !!Math.round(Math.random()) ? hasZero.indexOf(0) > -1 : withoutZero.indexOf(0) > -1;
Array.includes
var tempResult = !!Math.round(Math.random()) ? hasZero.includes(0) : withoutZero.includes(0);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Array.some
Array.filter
Array.indexOf
Array.includes
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0
Browser/OS:
Firefox 132 on Ubuntu
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array.some
9031.9 Ops/sec
Array.filter
9042.5 Ops/sec
Array.indexOf
262060.7 Ops/sec
Array.includes
280841.1 Ops/sec
Related benchmarks:
Some vs. Filter vs. indexOf vs. includes
Some vs Filter vs indexOf vs Includes vs Find
Some vs. Filter vs. indexOf v includes
Some vs. Filter vs. indexOf vs Includes
Array.prototype.some() vs. Filter vs. Array.prototype.indexOf()
Comments
Confirm delete:
Do you really want to delete benchmark?