Test name | Executions per second |
---|---|
map | 58.5 Ops/sec |
array | 58.5 Ops/sec |
obj | 61.2 Ops/sec |
var i = 0, count = 100000, a;
var map = new Map();
var array = [];
var obj = {};
for (i = 0; i < count; i++) {
const randomValue = ~~(Math.random() * 100);
map.set(i, randomValue);
array.push({id: i, randomValue});
obj[i] = randomValue;
}
for (i = 0; i < count; i++) {
a = map.get(i);
}
for (i = 0; i < count; i++) {
a = array.find(el => el.id = i);
}
for (i = 0; i < count; i++) {
a = obj[i]
}