Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.forEach vs for(const value of array) vs index vs Array.reverse + reversed index
(version: 0)
Comparing performance of:
Array.forEach vs for(const value of array) vs index vs Array.reverse + reversed index
Created:
4 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var array = [1, 3, 2]; for(let i = 0; i < 6; i++) { array.concat(array); };
Tests:
Array.forEach
array.forEach(d => { console.log(d); });
for(const value of array)
for(const value of array) { console.log(value); };
index
for(let index = 0; index < array.length; index++) { console.log(array[index]); };
Array.reverse + reversed index
array.reverse(); for(let index = array.length - 1; index >= 0; index--) { console.log(array[index]); };
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
Array.forEach
for(const value of array)
index
Array.reverse + reversed index
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
unshift vs concat vs spread of another array
spread vs concat vs unshift correct
spread vs concat first vs unshift
unshift vs spread vs concat
spread vs concat vs unshift1
Comments
Confirm delete:
Do you really want to delete benchmark?