Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Chrome 128
Linux
Desktop
3 months ago
Test name Executions per second
Map lookup 9433.5 Ops/sec
Obj lookup 8931.2 Ops/sec
Script Preparation code:
x
 
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;
Tests:
  • Map lookup

     
    for (i = 0; i < count; i++) {
      a = map.has('stringKey');
    }
  • Obj lookup

     
    for (i = 0; i < count; i++) {
      a = obj.hasOwnProperty('stringKey');
    }