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:
11 months ago
by:
Guest
Jump 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:
11 months 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
Test name
Executions per second
for-loop
50075924.0 Ops/sec
for..of
16686630.0 Ops/sec
Array.find()
49059276.0 Ops/sec
Related benchmarks:
find() vs for...of vs for-loop
find() vs for...of vs for-loop multi variable
For-loop vs For-Of vs Array.find
for loop vs for of
find() vs for...of vs for-ggggloop
find() vs for...of vs for-loop 2
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?