If I use .each()
both console logs return the same value, but if I use for
the second one returns only the array length, length of the array times. What's the difference between them? What am I missing?
//for (var i = 0; i < streamers.length; i++)
$.each(streamers, function(i,data) {
console.log(i);
$.getJSON('https://api.twitch.tv/kraken/streams/' + data + '?callback=?', function(data) {
console.log(i);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>