Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Looping with Index: forEach vs array.entries vs for
(version: 1)
Comparing performance of:
forEach vs array.entries vs for
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = [1,2,3,4,5];
Tests:
forEach
arr.forEach((item, index) => console.log(item + index))
array.entries
for(var [index, item] in arr.entries()){ console.log(item + index); }
for
for( var index = 0; index < arr.length; index++ ){ console.log(arr[index] + index); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
forEach
array.entries
for
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36
Browser/OS:
Chrome 139 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
forEach
81399.6 Ops/sec
array.entries
90822440.0 Ops/sec
for
97231.5 Ops/sec
Comments
Confirm delete:
Do you really want to delete benchmark?