async/await is freaking awesome, but there is one place where it’s tricky: inside a forEach() Let’s try something: const waitFor = (ms) => new Promise(r => setTimeout(r, ms)); [1, 2, 3].forEach(async (num) => {
await waitFor(50);
console.log(num);
}); console.log('Done'); If you run this code with node.js (≥ 7.6.0), this will happen: $ node…