Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
for vs for (reverse with length) vs every vs forEach with big array 2
(version: 0)
Comparing performance of:
for vs for (reverse with length) vs some vs every vs forEach
Created:
4 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function generateTestArray() { var result = []; for (let i = 0; i < 1000000; ++i) { result.push({ a: i, b: i / 2, r: 0, }); } return result; } var array = generateTestArray();
Tests:
for
for (var i = 0; i < array.length; i++) { array[i]; }
for (reverse with length)
var length = array.length; for (var i = length; --i >= 0;) { array[i]; }
some
array.some(function(i) { array[i]; return false; });
every
array.every(function(i) { array[i]; return true; });
forEach
array.forEach(function(i) { array[i]; });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
for
for (reverse with length)
some
every
forEach
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:
Regular for vs forEach
foreach vs for..of
for vs foreach vs map 2
For loop vs <Array>.forEach() vs for...of loop
for vs foreach123
Comments
Confirm delete:
Do you really want to delete benchmark?