title: Iterate through dictionaries in javascript and access values?
body: <p>I am not a javascript expert, so I am sure what I am trying to do is pretty straight forward, but, here it is:</p>
  
  <p>I have an array that comes down from a database, it looks like this:</p>
  
  <pre><code>[{"name":"aName","lastName":"aLastname"},{"name":"bName","lastName":"bLastname"}]
  </code></pre>
  
  <p>I want to iterate through all dictionaries found in the array and access the <code>aName</code>, <code>aLastname</code> etc... so all possible values found in each dictionary, a dictionary at the time.</p>
  
  <p>I tried using <code>eval()</code>, I tried to use <code>JSON.parse</code>, but <code>JSON.parse</code> I think was complaining because I think the object was already coming down as JSON.</p>
  
  <p>How can I do that in javascript?</p>
  
  <p>Thanks</p>
  
  <p>So then I tried to do what was suggested by the "duplicate" answer comment... I did this:</p>
  
  <pre><code>        for(var i=0; i&lt;array.length; i++) {
              var obj = array[i];
              for(var key in obj) {
                  var value = obj[key];
                  console.log(key+" = "+value);
              }
          }
  </code></pre>
  
  <p>Problem is that the log is out of order. I get this:</p>
  
  <pre><code>name = aName
  name = bName
  lastName = aLastName
  lastName = bLastName
  </code></pre>
  
  <p>I want to be sure I iterate through the properties and values in order one dictionary at the time.</p>
  
  <p>What am  missing here?</p>