Код: Выделить всё
async function processData(arr) {
let result = [];
arr.forEach(async (item) => {
const value = await Promise.resolve(item * 2);
result.push(value);
});
return result;
}
processData([1, 2, 3]).then(res => console.log(res));
// Expected output: [2, 4, 6]Я ожидал, что результат будет таким:
Код: Выделить всё
[2, 4, 6]
Подробнее здесь: https://stackoverflow.com/questions/798 ... ait-in-jav
Мобильная версия