async foreach
[1, 2, 3].forEach(async (num) => { await waitFor(50); console.log(num);});console.log('Done');
async foreach
[1, 2, 3].forEach(async (num) => { await waitFor(50); console.log(num);});console.log('Done');
foreach await js
async function printFiles () {
const files = await getFilePaths();
for (const file of files) {
const contents = await fs.readFile(file, 'utf8');
console.log(contents);
}
}
js await in foreach
// Javascript will proceed to call the code that comes AFTER the forEach loop,
// and then execute the code within the loop. This is because forEach is not
// async-aware. YOU CANNOT USE AWAIT IN FOREACH. Use a regular for loop instead.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us