Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
find() vs for...of vs for-loop simple
Testing the difference between native loops and find()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:138.0) Gecko/20100101 Firefox/138.0
Browser:
Firefox 138
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
Array.find()
30.4M/s
for-loop
14.9M/s
for..of
9.4M/s
View exact numbers
Test name
Executions per second
✓
Array.find()
30,372,066 Ops/sec
for-loop
14,871,933 Ops/sec
for..of
9,376,099 Ops/sec
HTML Preparation code:
<div id='test'></div>
Script Preparation code:
var arr = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.".split(" ");
Tests:
for-loop
let val; for(i=0; i<arr.length; i++){ var value = arr[i]; if (value === 'dolore') { val = value; break; } }
for..of
let val; for (var value of arr) { if (value === 'dolore') { val = value; break; } }
Array.find()
let val = arr.find(value => value === 'dolore');