Would it make any difference if I have:
async function test () {
const foo = await bar()
return Promise.all([promise1, promise2])
}
instead of:
async function test () {
const foo = await bar()
const [result1, result2] = await Promise.all([promise1, promise2])
// Given that I don't care about result1, result2 in this `test` function
return [result1, result2]
}
I get the same result if I do either. E.g. I can do this for either case:
test().then(([result1, result2]) => { ... })
but I am more curious about the underlying mechanism how they both behave the same.
In other words, how does async function handle it if inside the function I return a promise instead of a value?