title: Loop Through Array inside Object in Javascript
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/684672/loop-through-json-object">Loop through Json object</a>  </p>
  </blockquote>
  
  
  
  <pre><code>{
    "data": [
      {
        "name": "Jen",
        "id": "1"
      },
      {
        "name": "Steve",
        "id": "8"
      }
    ]
  }
  </code></pre>
  
  <p>A server I'm interacting with responds with the above.</p>
  
  <p>I'm trying to loop through it<code>enter code here</code> for the For..in statement.</p>
  
  <p>This is what I'm trying to do:</p>
  
  <pre><code>for (var item in response.data) {
    console.log(item.name);
  }
  </code></pre>
  
  <p>This doesn't work.
  What went wrong?</p>
  
  <p>Thank you</p>
  
  <p>I GOT IT to work with the following after reading the comment:</p>
  
  <pre><code>for (var item in response.data) {
    console.log(response.data[item].name);
  }
  </code></pre>
  
  <p>I was able to get a list of names...</p>
  
  <p>Can someone dissect the response as to why it worked?</p>