Output: Promise.all and Promise.allSettled on the same inputs with one rejection
MediumP2Output
What does this code print?
1const ok = Promise.resolve(1);2const bad = Promise.reject(new Error('boom'));3const slow = new Promise((resolve) => setTimeout(() => resolve(3), 0));45Promise.all([ok, bad, slow]).then(6 (v) => console.log('all', v),7 (e) => console.log('all rejected:', e.message)8);9Promise.allSettled([ok, bad, slow]).then((results) => {10 console.log(results.map((r) => r.status));11});
Saved automatically
One line per console.log. Arrays as [1, 2, 3], objects as { a: 1 }, an uncaught error as Uncaught TypeError: message (Chrome and Node wording).
Hints
Saved automatically