Here is the code somebody else posted as a solution:
for (var i = 0; i < array.length; i++) {
(function(i) { // protects i in an immediately called function
  $.getJSON('/api.php?action=query&list=querypage&qppage=' + array[i] + '&format=json', function (data) {
    $('#' + array[i]).text(data.query.querypage.results.length);
  });
})(i);
}
Specifically, what does the (i) do at the end of the function?
 
    