I was looking at the MDN documentation for async await and found that there is an alternative to promise.all
so,
if coffee , tea and description are three promises we can await them all
let values = await Promise.all([coffee, tea, description]);
But the MDN also gives example of slow and fast async await:
Example of slow async await:
async function timeTest() {
await timeoutPromise(3000);
await timeoutPromise(3000);
await timeoutPromise(3000);
}
Example of fast async await:
async function timeTest() {
const timeoutPromise1 = timeoutPromise(3000);
const timeoutPromise2 = timeoutPromise(3000);
const timeoutPromise3 = timeoutPromise(3000);
await timeoutPromise1;
await timeoutPromise2;
await timeoutPromise3;
}
I am confused about fast async await. Does it work similar to promise.all()? Is it better than promise.all()?
If we are writing multitple awaits in different lines how is it any different from slow async await?