.entries, for of, and .forEach

Benchmark created on


Setup

const obj = {}
for(let i = 0; i< 10; i++){
	obj[i] = i + 2
}

Test runner

Ready to run.

Testing in
TestOps/sec
Object.entries().forEach() summation
let sum = 0
Object.entries(obj).forEach(([key,value])=>{
	if(key%2) sum += value
})
ready
for loop
let sum = 0
for(const key in obj){
	if(key%2) sum += obj[key]
}
ready

Revisions

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