Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
find faster - for vs find vs map vs foreach
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser:
Chrome 136
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
prototype.find
3.9M/s
for
958K/s
forEach
40K/s
map
38K/s
View exact numbers
Test name
Executions per second
✓
prototype.find
3,942,704 Ops/sec
for
958,381 Ops/sec
forEach
40,269 Ops/sec
map
38,459 Ops/sec
Script Preparation code:
var arr = [] let i = 0 let len = 1000 for(;i<len;i++) { arr.push(i) }
Tests:
for
let i = 0 let len = arr.length let foundIndex = -1 for(;i<len;i++) { if (arr[i] > 999){ return i } }
prototype.find
const found = arr.find(function(element) { return element > 999 })
forEach
let foundForEachIndex = -1 arr.forEach(function (item){ if (item[i] > 999){ foundForEachIndex = i return } })
map
let foundMapIndex = arr.map(item => { if (item[i] > 999){ return i } })