📅  最后修改于: 2022-03-11 15:04:25.178000             🧑  作者: Mango
//use let keywork and i will increment correctly inside loops
for (let i = 0; i < a.length; i++) {
makeHttpReqest("http://www.codegrepper.com", function(response) {
// i will increment correctly here;
});
}
//Alternatively, if you can't use let, this syntax will work too
for (var i = 0; i < a.length; i++) (function(i)
{
makeHttpReqest("http://www.codegrepper.com", function(response) {
// i will increment correctly here;
});
}) (i);