0

If the a and b promise functions exist, do the two codes below work the same?

await Promise.all([a(), b()]);

await (a(), b());
VLAZ
  • 26,331
  • 9
  • 49
  • 67
Hyeongrok
  • 31
  • 1
  • 5
  • 1
    What happens when you test it? – David Sep 15 '22 at 13:12
  • 1
    The second one is just the comma operator, it's not anywhere near awaiting both: [What does the comma operator do in JavaScript?](https://stackoverflow.com/q/3561043) – VLAZ Sep 15 '22 at 13:13
  • `Promise.all([..])` returns a promise Object, so using it with await is similar to when you call the promise object with `.then().catch()` – sohaieb azaiez Sep 15 '22 at 13:13
  • 3
    The simple answer is No. It will just wait for `b`, and `a` will be left as a promise to resolve. Were as `await Promise.all` is going to wait for `a` and `b` to resolve, and return the resolved results in an array.. – Keith Sep 15 '22 at 13:17

0 Answers0