For-of vs For Each (v2)

Revision 2 of this benchmark created on


Setup

const arr = new Array(100000).fill("").map((_, i) => Math.random())

Test runner

Ready to run.

Testing in
TestOps/sec
For-of
let total = 0;
for(const a of arr) {
	total += a;
}
console.log(total);
ready
For Each
let total = 0;
arr.forEach((a) => {
	total += a;
});

console.log(total);
ready

Revisions

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