для цикла с счетчиком: < /p>
for(let i = page; i < numPages + 1; i++){
const fn = async() => {
const res = await xxx(i);
console.log("page", i);
return res;
}
promises.push(fn);
}
< /code>
wherp incule с тем же типом счетчика: < /p>
while(page < numPages + 1){
page++;
const fn = async() => {
const res = await xxx(page);
console.log("page", page);
return res;
}
promises.push(fn);
}
< /code>
они дают разные результаты.
для IS отображает счетчик нормально. < /p>
Но пока отображает последнее значение каждый раз.>
Подробнее здесь: https://stackoverflow.com/questions/795 ... while-loop