JavaScript-Quiz: Promise.all, allSettled, race & any

JavaScript has four ways to combine promises, and each one reacts differently to failures. This quiz tests Promise.all(), Promise.allSettled(), Promise.race() and Promise.any(), the order of their results and what they do when something rejects.

Mittel 10 Fragen ~6 Minuten Bestanden ab 80% Node.js 22

Modus wählen

Du spielst als Gast: Melde dich an, damit XP und Serie gespeichert werden.

Beispielfrage

Frage 1 von 10

What does this print?

const wait = (ms, v) => new Promise(r => setTimeout(() => r(v), ms));

Promise.all([wait(10, "slow"), wait(1, "fast"), 42])
  .then(results => console.log(results.join(",")));
Lösung zeigen

C. slow,fast,42 Promise.all() gives results in the same order as the input, no matter which finishes first. Plain values like 42 are treated as already resolved promises.

Darum geht es in diesem Quiz

  • Promise.all() keeps input order and fails fast
  • Promise.allSettled() reports every result
  • Promise.race() settles with the first one to settle
  • Promise.any() and AggregateError
  • Choosing the right combinator for a real task

Häufige Fragen

Brauche ich ein Konto?

Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.

Kann ich es wiederholen?

Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.