Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.some() vs Array.map().includes()
(version: 1)
Comparing performance of:
Array.map().includes() vs Array.some()
Created:
5 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const arrayLength = 50; const randomIndexForIdToFind = Math.random() * (arrayLength - 1) + 1; const idToFind = 'foo'; const arr = []; for (let i = 0; i < arrLength ; i++) { if (i === randomIndexForIdToFind) { arr.push({ foo: { id: idToFind }}); } else { arr.push({ foo: { id: 'bar' }}); } }
Tests:
Array.map().includes()
arr.map(e => e.foo.id).includes(idToFind);
Array.some()
arr.some(e => e.foo.id === idToFind);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Array.map().includes()
Array.some()
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:145.0) Gecko/20100101 Firefox/145.0
Browser/OS:
Firefox 145 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array.map().includes()
122370088.0 Ops/sec
Array.some()
1828167296.0 Ops/sec
Related benchmarks:
JS Some vs Includes
map vs findIndex v2
filter_map vs reduce
filter_map vs reduce 2
Object arrays: findIndex vs forOf loop
at vs index
Object arrays: findIndex vs for loop 22
Test Loop Set Data
map vs reverse for vs for vs push vs unshift
Comments
Confirm delete:
Do you really want to delete benchmark?