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:
8 months ago
by:
Guest
Go 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:
8 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
Array.some()
1828.2M/s
Array.map().includes()
122.4M/s
View exact numbers
Test name
Executions per second
✓
Array.some()
1,828,167,296 Ops/sec
Array.map().includes()
122,370,088 Ops/sec
Related benchmarks
JS Some vs Includes
at vs index
Test Loop Set Data
map vs reverse for vs for vs push vs unshift
Comments
Confirm delete:
Do you really want to delete benchmark?