title: Javascript object reference by variable
body: <p>I have an object like:</p>
  
  <pre><code>var theObject = { 
      keyName1: { keyName2: value2, keyName3: value3, keyName4: value40 },
      ...,
      keyName10: { keyName2: value6, keyName3: value7, keyName4: value8 }
  }
  </code></pre>
  
  <p>I know I can reference value7 by <code>theObject["keyName10"]["keyName3"]</code> or <code>theObject.keyName10.keyName3</code>
  but what I need is to set a variable to something like the search path and somehow pass it to <code>theObject</code> and get value7 directly.</p>
  
  <p>Something like:</p>
  
  <pre><code>var path = keyName10.keyName3;
  var myValue = theObject(path);
  </code></pre>
  
  <p>Objects can be even further into the object inception.
  Right now I'm solving it by horrible looking nestled for-loops.
  Is there a better way I missed?</p>