object.entries vs for in

Benchmark created on


Setup

const o = {};

for (let i = 0; i < 100_000_000; i += 1) {
	o[i] = i;
}

Test runner

Ready to run.

Testing in
TestOps/sec
object.entries
Object.entries(o).forEach(([k, v]) => {
	v;
});
ready
for in
for (k in o) {
	if (!Object.prototype.hasOwnProperty.call(o, k)) return;
	const v = o[k];
	v;
}
ready

Revisions

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