For..of vs forEach (v5)

Revision 5 of this benchmark created on


Setup

let list = [];
var x = 0;

for (let i = 0; i < 10000; i++) {
	list.push(i);
}

Teardown

x = undefined;

Test runner

Ready to run.

Testing in
TestOps/sec
For...of
for (const item of list) {
	x = item;
}
ready
forEach
list.forEach((item) => x = item);
ready

Revisions

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