title: How can I access a value in a multidimensional object with unique keys in Javascript?
body: <p>How can I access the value for <code>name</code> in the object below? Also, does this object have a special name since unique keys (i.e. <code>friend1</code> and <code>friend2</code>) hold other key/value pairs?</p>
  
  <pre><code>    var friends = {
          "friend1":{
              "name":"ana",
              "position":1,
              "spouse":"billy"
          },
          "friend2":{
              'name':'keri',
              'position':2,
              'spouse':'david'
          }
      };
  </code></pre>
  
  <p>Please note that this is a simplified version of the project I am working on. I realize there is a better way to hold data for a list of friends– the point to keep in mind is that the key that holds the other key/value pairs is unique.</p>
  
  <p>I have tried this but it obviously does not work (i.e. "undefined"):</p>
  
  <pre><code>for( i = 0; i &lt; Object.keys(friends).length; i++ ) {
    var theFriend = [i].name;
    alert(theFriend);
  }
  </code></pre>
  
  <p>Here is a <a href="https://jsfiddle.net/samurai_jane/mu7jaL4h/5/" rel="nofollow">fiddle</a>.</p>