JavaScript Promises and Async/Await Quiz
JavaScript runs one thing at a time. Synchronous code runs first, then promise callbacks (microtasks), then timers and other tasks. Knowing this order lets you predict exactly what async code will log.
These questions cover promises, async/await, Promise.all, setTimeout and the event loop.
Promises & Async questions
- Why does an arrow function in setTimeout keep this?
- Why does a Promise run before setTimeout 0?
- What does an async function return in JavaScript?
- What runs first after await in JavaScript?
- Is the Promise constructor callback synchronous?
- What happens when one promise in Promise.all rejects?
- What is the difference between Promise.all and Promise.allSettled?
- Why does a .then() without return pass undefined?
- What happens if you call resolve twice in a Promise?
- In what order do setTimeout callbacks run?
- What is queueMicrotask in JavaScript?
- Why doesn't try/catch catch an error from an async function?