Test name | Executions per second |
---|---|
Map lookup | 9433.5 Ops/sec |
Obj lookup | 8931.2 Ops/sec |
var map = new Map();
var obj = {};
var j = 0;
while (j < 10000) {
var key = "Key_" + j;
map.set(key, 5);
obj[key] = 5;
j += 1;
}
var stringKey = 'asdfasdjfa;sjfjaklfjklsjklajjjj;jlsjfajdfsfjs;fjsfka';
var i = 0, count = 1000, a;
for (i = 0; i < count; i++) {
a = map.has('stringKey');
}
for (i = 0; i < count; i++) {
a = obj.hasOwnProperty('stringKey');
}