Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
forEach vs for of (with Iterator)
(version: 1)
Comparing performance of:
forEach vs for of
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ async function globalMeasureThatScriptPrepareFunction() { // This function is optional, feel free to remove it. // await someThing(); }
Tests:
forEach
/*When writing async/deferred tests, use `deferred.resolve()` to mark test as done*/ const arr = new Array(1000); arr[Symbol.iterator]().forEach(v => { var a = v });
for of
const arr = new Array(1000); for (var v of arr) { var a = v }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
forEach
for of
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
10 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Browser/OS:
Chrome 138 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
forEach
99892.5 Ops/sec
for of
1819679.5 Ops/sec
Related benchmarks:
reate array by lenght
Assigning new variable
Test array concat
Test array concat with larger array
Counter Increasement v5
Nullish vs If
js mul vs pow
Test array ops
forEach vs for of (with Iterator) 2
Comments
Confirm delete:
Do you really want to delete benchmark?