DEV Community

Discussion on: 7 Hardest Node.js Interview Questions & Answers

Collapse
 
asyncawait3 profile image
AsyncAwait • Edited

In the last example since there is now dependency in async functions, why not just:

const check = (req, res) =>
  Promise.all([someOtherFunction(), somethingElseFunction()])
    .then(() => res.send('result'))
    .catch((error) => res.send(error.stack))
Collapse
 
jexah profile image
Jeremy Short

This is not correct, because in your code, both functions will run concurrently, whereas in the original code, they run sequentially.

Collapse
 
pawda profile image
Memoria

only if "somethingElseFunction" does not depends on the result of "someOtherFunction"