array forEach, for of vs set forEach, for of

Benchmark created on


Setup

const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const set = new Set(arr )

Test runner

Ready to run.

Testing in
TestOps/sec
set foreach
let i = 0;

set.forEach(val => {
	i += val
})
ready
set for of
let i = 0;

for (const val of set) {
	i += val
}
ready
array foreach
let i = 0;

arr.forEach(val => {
	i += val
})
ready
array for of
let i = 0;

for (const val of arr) {
	i += val
}
ready

Revisions

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