title: Can you explain how JSON objects are stored inside a Javascript object?
body: <p>Here I'm iterating over JSON objects stored inside a javascript object and print some of it's values.</p>
  
  <pre><code> database.ref().once("value", function (snap) {
      //store javascript object containing JSON objects in scores variable.
      scores = snap.val();
  
      for(var key in scores){
          console.log(scores[key].Name);
      }
  });
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/tVLcA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tVLcA.png" alt="enter image description here"></a></p>
  
  <p>scores object look like this.</p>
  
  <p><a href="https://i.stack.imgur.com/TmPaa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TmPaa.png" alt="enter image description here"></a></p>
  
  <p>How does the for loop retrieve the key in each JSON object and store in the variable named "key"? </p>
  
  <p>Since scores is not an array but a javascript object how does a for loop work at all?</p>
  
  <p>For example <code>scores[1].Name</code> won't work. So, it's not index based.</p>