Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
For loops methods benchmark
(version: 0)
Comparing performance of:
Regular for loop vs Regular for loop with length variable vs For .. of vs For .. in vs Backwards for loop without increment vs Foreach loop vs Backwards for loop
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var array = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
Tests:
Regular for loop
for (let i = 0; i < array.length; i++) console.log(array[i]);
Regular for loop with length variable
for (let i = 0, len = array.length; i < len; i++) console.log(array[i]);
For .. of
for (const value of array) console.log(value);
For .. in
for (const i in array) console.log(array[i]);
Backwards for loop without increment
for (let i = array.length; i--;) console.log(array[i]);
Foreach loop
array.forEach((value, index) => console.log(value));
Backwards for loop
for (let i = array.length; i >= 0; i--) console.log(array[i]);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (7)
Previous results
Fork
Test case name
Result
Regular for loop
Regular for loop with length variable
For .. of
For .. in
Backwards for loop without increment
Foreach loop
Backwards for loop
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!
Comments
Confirm delete:
Do you really want to delete benchmark?