Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
for...of vs for-loop vs find()
(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 = ['hello', 'a', 'b']; let val; for(i=0; i<arr.length; i++){ var value = arr[i]; if (value === 'b') { val = value; break; } }
for..of
var arr = ['hello', 'a', 'b']; let val; for (var value of arr) { if (value === 'b') { val = value; break; } }
Array.find()
var arr = ['hello', 'a', 'b']; let val = arr.find(node => node === 'b');
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 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0
Browser/OS:
Firefox 140 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
for-loop
50.1M/s
Array.find()
49.1M/s
for..of
16.7M/s
View exact numbers
Test name
Executions per second
✓
for-loop
50,075,924 Ops/sec
Array.find()
49,059,276 Ops/sec
for..of
16,686,630 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
Comments
Confirm delete:
Do you really want to delete benchmark?