Map vs Object

Benchmark created on


Setup

const myMap = new Map();
const myObject = {};
for (let i = 0; i < 10000; i++) {
  myMap.set(`key${i}`, `value${i}`);
  myObject[`key${i}`] = `value${i}`;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Map destructure
const x = [...myMap.values()];
ready
Object toValues
const y = Object.values(myObject);
ready

Revisions

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