title: What is the run time complexity O(?) for JavaScript to access an object property?
body: <pre><code>var obj = {};
  
  obj["A"] = true;
  obj["B"] = true;
  obj["C"] = true;
  
  console.log(obj["D"]);
  </code></pre>
  
  <p>The above code will print "undefined". What is the runtime complexity when javascript is trying to access obj["D"] ? I guess it will be the same as it is trying to access obj["A"]?</p>
  
  <p>The reason why I am asking this is because I am comparing the efficiency between these two code:</p>
  
  <pre><code>//Code 1
  var x = ["a","b","c"];
  var y = ["a","b","c"];
  
  for(i = 0; i&lt;x.length; i++){
      for(j = 0; j&lt;y.length; j++){
          console.log(i==j);
      }
  }
  
  //Code2
  var _x = {};
  var _y = ["a", "b", "c"];
  
  _x["a"] = true;
  _x["b"] = true;
  _x["c"] = true;
  
  for(i = 0; i&lt;_y.length; i++){
      if(_x[_y[i]] != undefined){
          console.log("something");
      }
  }
  </code></pre>
  
  <p>I would like to know which one is more efficient in term of runtime complexity.
  I suppose if accessing an object property takes O(n), then the runtime of the two code would be the same?</p>