Here I'm iterating over JSON objects stored inside a javascript object and print some of it's values.
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);
}
});
scores object look like this.
How does the for loop retrieve the key in each JSON object and store in the variable named "key"?
Since scores is not an array but a javascript object how does a for loop work at all?
For example scores[1].Name
won't work. So, it's not index based.