Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
find() vs for...of vs for-loop vs reverse-for
Testing the difference between native loops and find()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Array.find()
103.8M/s
for..of
100.3M/s
reverse for
83.1M/s
for-loop
74.2M/s
View exact numbers
Test name
Executions per second
✓
Array.find()
103,775,640 Ops/sec
for..of
100,333,840 Ops/sec
reverse for
83,085,392 Ops/sec
for-loop
74,220,384 Ops/sec
HTML Preparation code:
<div id='test'></div>
Script Preparation code:
var arr = [ {text: "foo"}, {text: "bar"}, {text: "baz"}, ];
Tests:
for-loop
let val; for(var i=0; i<arr.length; i++){ var value = arr[i]; if (value.text === 'baz') { val = value; break; } }
for..of
let val; for (var value of arr) { if (value.text === 'baz') { val = value; break; } }
Array.find()
let val = arr.find(node => node.text === 'baz');
reverse for
let val; for(var i=arr.length-1; i>-1; i--){ var value = arr[i]; if (value.text === 'b') { val = value; break; } }