5 exercises on async patterns and promises vocabulary.
0 / 5 completed
1 / 5
In JavaScript, what does a Promise represent?
Promise: an object representing the eventual result of an async operation. It is in one of three states: pending, fulfilled, or rejected, and settles exactly once.
2 / 5
What is the key difference between Promise.all and Promise.allSettled?
all vs allSettled:Promise.all short-circuits and rejects on the first failure. Promise.allSettled always resolves with an array describing each promise's status (fulfilled or rejected), so you see all results.
3 / 5
Why is async/await often preferred over chained .then() calls?
async/await: syntactic sugar over promises that lets asynchronous code read top-to-bottom. Errors propagate through try/catch instead of .catch() chains, reducing nesting and improving clarity.
4 / 5
What does Promise.race do?
race: returns a promise that settles with the outcome of whichever input promise settles first. A common use is implementing timeouts by racing an operation against a delayed rejection.
5 / 5
What is the danger of a floating (unhandled) promise?
Floating promise: calling an async function without awaiting or chaining .catch() means a rejection is not handled, causing silent failures and unhandled-rejection warnings. Always await or explicitly handle the result.