for of in

Benchmark created on


Description

test for of vs for in by object

Setup

const testObject = {
	a: 1,
	b: 2
};

Test runner

Ready to run.

Testing in
TestOps/sec
for in
for(let i = 0; i <= 1000000; i++){
	
	let str = [];
	
	for(const key in testObject){
	
		let value = testObject[key];
	
		str.push(key + ":" + value); 
	}
}
ready
for of
for(let i = 0; i <= 1000000; i++){
	
	let str = [];
	
	for(const [key, value] of Object.entries(testObject)){
		str.push(key + ":" + value);	
	}
}
ready

Revisions

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