Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
find vs fors
(version: 1)
Testing the difference between native loops and find()
Comparing performance of:
for-loop vs for..of vs Array.find()
Created:
one year ago
by:
Guest
Go to the latest result
HTML Preparation code:
<div id='test'></div>
Tests:
for-loop
var arr = ['a', 'b', 'test']; let val; for(i=0; i<arr.length; i++){ var value = arr[i]; if (value === 'test') { val = value; break; } }
for..of
var arr = ['a', 'b', 'test']; let val; for (var value of arr) { if (value === 'test') { val = value; break; } }
Array.find()
var arr = ['a', 'b', 'test']; let val = arr.find(node => node.id === 'test');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
for-loop
for..of
Array.find()
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15
Browser/OS:
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
for-loop
75.7M/s
Array.find()
74.2M/s
for..of
68.8M/s
View exact numbers
Test name
Executions per second
✓
for-loop
75,654,664 Ops/sec
Array.find()
74,189,480 Ops/sec
for..of
68,832,424 Ops/sec
Related benchmarks
find() vs for...of vs for-loop
for...in vs for...of vs for-loop
find() vs for...of vs for-loop v2
find() vs for...of vs for-loop 2222
find() vs for...of vs for-loop vs reverse-for
for...of vs for-loop vs find()
Comments
Confirm delete:
Do you really want to delete benchmark?