Map vs Object

Benchmark created on


Setup

var arr = ["a", "b", "c", "d", "e"];

Test runner

Ready to run.

Testing in
TestOps/sec
Obj
const obj = {};

for (const i of arr) {
	obj[i] = i;
}

for (const i of arr) {
	console.log(i in obj);
}
ready
Map
const map = new Map();

for (const i of arr) {
	map.set(i, i);
}

for (const i of arr) {
	console.log(map.has(i));
}
ready

Revisions

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