If you want to loop through objects in an array, you can do this
for(var i=0; i<your_array.length; i++){ var object = your_array[i] //your code here }
If you want to loop through properties in an object, you can do this
for(var propName in object){ var prop = object[propName] //Your code here }
If you only want to loop through properties with numeric format name, you can do this
for(var propName in object){ if(!isNaN(propName)){ var prop = object[propName] //Your code here } }
Altogether,
for(var i=0; i<your_array.length; i++){ var object = your_array[i]; console.log("From " + object.start_time + " to " + object.end_time); for(var propName in object){ if(!isNaN(propName)){ var playerIndex = propName; var player = object[propName] console.log("Index = " + playerIndex + ", ID = " + player.player_id + ", Name = " + player.player_name); } } }
Output
From 17:40:00 to 18:00:00 Index = 0, ID = 138, Name = Jay Patoliya From 17:00:00 to 18:00:00 Index = 0, ID = 138, Name = Jay Patoliya From 17:40:00 to 18:00:00 Index = 0, ID = 138, Name = Jay Patoliya Index = 1, ID = 4, Name = Jay Patoliya Index = 2, ID = 49, Name = John DiFulvio
iteratein reality