Foreach (v2)

Revision 2 of this benchmark created on


Setup

const collection = Array(5000).map((el, i) => i);

Test runner

Ready to run.

Testing in
TestOps/sec
for of
let sum = 0;
for(let el of collection)
{
	sum += el;
}
ready
for i
let sum = 0;
for(let i = 0; i < 5000; i++)
{
	sum += collection[i];
}
ready
forEach
let sum = 0;
collection.forEach(el =>
{
	sum += el;
});
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.