title: How does JavaScript find values when using dot notation or key
body: <p>I have a large JavaScript object that contains properties that are added and deleted as and when required. Something similar to this:</p>
  
  <pre><code>var data = {
  
    data1: {
        subscribers : ["sub1", "sub2"]
    },
  
    data2: {
        subscribers : ["sub1", "sub2"]
    }
  
    //[0...*]
  
  };
  </code></pre>
  
  <p>I want the subscribers from "data2" so I use <code>data["data2"].subscribers</code> to access this information.</p>
  
  <p>But my <strong>questions</strong> are:</p>
  
  <ul>
  <li><em>What are JavaScript internal workings of accessing properties like this (dot notation, using the property name)?</em></li>
  <li><em>Does the size of the object have an effect on how fast the subscribers array is returned?</em></li>
  </ul>
  
  <hr>
  
  <p>My guess would be that the size would effect the speed of receiving the returned data because I think the way that JavaScript accesses the properties is using a for loop over the objects:</p>
  
  <pre><code>function getSubs(name) {
      for(var prop in data) {
          if(prop === name) {
              return data[prop].subscribers;
          }
      }
  }
  var subs = getSubs("data2");
  </code></pre>