Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Some vs. Filter vs. indexOf vs. Includes vs. Find - nested#223423
(version: 0)
Comparing performance of:
Array.filter vs Array.find vs Array.includes vs Array.reduce vs for
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var array = []; for (var i = 0; i < 10000; i++) { const obj = { data: { bool: !!Math.floor(Math.random() * 100 > 75) }, str: Math.floor(Math.random() * 100) }; array.push(obj); array.push({...obj, str: obj.str + 1 }); }
Tests:
Array.filter
var tempResult = array.filter(({ data, str }) => { const shouldBeTrue = data.bool; const isSmall = str < 1; return shouldBeTrue && isSmall; });
Array.find
var tempResult = array.find(({ data, str }) => { const shouldBeTrue = data.bool; const isSmall = str < 1; return shouldBeTrue && isSmall; });
Array.includes
var tempResult = array.includes(({ data, str }) => { const shouldBeTrue = data.bool; const isSmall = str < 1; return shouldBeTrue && isSmall; });
Array.reduce
var tempResult = array.reduce((found, { data, str }) => { const shouldBeTrue = data.bool; const isSmall = str < 1; if(shouldBeTrue && isSmall) { return { count: found.count + 1 }; } else { return found; } }, { found: 0 });
for
var tempResult = []; for (var i = 0; i < array.length; i++) { const {data, str} = array[i]; const shouldBeTrue = data.bool; const isSmall = str < 1; if(shouldBeTrue && isSmall) { tempResult.push(array[i]); } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Array.filter
Array.find
Array.includes
Array.reduce
for
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:
IndexOf vs Includes array of numbers
IndexOf vs Includes vs find
Array find with indexOf vs includes
array indexOf vs includes vs some using numbers
find vs includes vs indexof
Comments
Confirm delete:
Do you really want to delete benchmark?