Back to the Catalog
javascript
async

Master JavaScript Promise & Async Execution

100 questions

Step through the event loop, microtask & macrotask queues, async/await suspension, and tricky async patterns. Detailed MDN-linked explanations reveal after every answer.

Questions

  1. Not answered. In what order do the values log?
  2. Not answered. In what order do the values log?
  3. Not answered. In what order do the values log?
  4. Not answered. In what order do the values log?
  5. Not answered. In what order do the values log?
  6. Not answered. Two timers are registered with the same delay. In what order do the values log?
  7. Not answered. What is the state of p at the moment console.log reads it?
  8. Not answered. Which of these schedule work on the microtask queue? (Select all that apply.)
  9. Not answered. Which word is logged first?
  10. Not answered. When does the event loop process the microtask queue?
  11. Not answered. In what order do the values log?
  12. Not answered. A promise is resolved and rejected multiple times. What logs?
  13. Not answered. What does throwing inside an executor do?
  14. Not answered. The executor never calls resolve or reject. What logs?
  15. Not answered. What happens when you construct a promise without an executor: new Promise()?
  16. Not answered. A promise is resolved with another promise. In what order do the values log?
  17. Not answered. The resolver is captured and called later. In what order do the values log?
  18. Not answered. Promise.resolve receives a custom thenable. In what order do the values log?
  19. Not answered. In what order do the values log?
  20. Not answered. The first callback has no return. What logs?
  21. Not answered. .then is called with a non-function argument. What logs?
  22. Not answered. One callback returns a promise. Where does b land relative to the t chain?
  23. Not answered. Several handlers are attached to the same promise. What logs?
  24. Not answered. One chain and one fork on the same promise. In what order do the values log?
  25. Not answered. Two independent chains. In what order do the values log?
  26. Not answered. In what order do the values log?
  27. Not answered. What does finally do to the value flowing through?
  28. Not answered. Is the promise returned by .then the same object?
  29. Not answered. Which call is promise.catch(handler) exactly equivalent to?
  30. Not answered. The fulfillment handler throws. Which handler catches it?
  31. Not answered. What arguments does a finally callback receive?
  32. Not answered. The finally callback throws. What logs?
  33. Not answered. In what order do the values log?
  34. Not answered. What happens to the .then between the rejection and the .catch?
  35. Not answered. The first .catch re-throws. What logs?
  36. Not answered. Two .catch links in a row. What logs?
  37. Not answered. An async function with no await. In what order do the values log?
  38. Not answered. In what order do the values log?
  39. Not answered. Both awaits receive null, not a promise. In what order do the values log?
  40. Not answered. Two async functions run "concurrently". What does the final log show?
  41. Not answered. Nested async calls. In what order do the values log?
  42. Not answered. When a awaits b(), when does b's body run?
  43. Not answered. What does calling an async function return?
  44. Not answered. Three async functions return the same value three ways. In what order do the labels log?
  45. Not answered. What happens when you use await inside a regular (non-async) function?
  46. Not answered. Where is top-level await (outside any function) allowed?
  47. Not answered. Async IIFEs are passed to Promise.all. In what order do the values log?
  48. Not answered. In what order do the values log?
  49. Not answered. The same promise is awaited twice. What logs?
  50. Not answered. Inside an async function, what number does the expression await 5 evaluate to?
  51. Not answered. The second promise finishes first. What does Promise.all deliver?
  52. Not answered. One input rejects immediately. In what order do the values log?
  53. Not answered. Promise.all receives an empty array. What logs?
  54. Not answered. The input mixes plain values and promises. What logs?
  55. Not answered. A fulfillment at 10ms races a rejection at 30ms. What logs?
  56. Not answered. Promise.race receives an empty array. What logs?
  57. Not answered. The fastest promise rejects. What does Promise.any deliver?
  58. Not answered. Every input rejects. What logs?
  59. Not answered. One of three steps fails under Promise.allSettled. What logs?
  60. Not answered. Which combinator's returned promise never rejects?
  61. Not answered. A 50ms operation races a 20ms timeout. What logs?
  62. Not answered. Which combinators can settle before all of their inputs have settled? (Select all that apply.)
  63. Not answered. An async function throws. In what order do the values log?
  64. Not answered. An async function is called without await. What logs (besides any runtime warning)?
  65. Not answered. Can this try/catch (or a promise .catch) catch an error thrown in a timer callback?
  66. Not answered. forEach with an async callback. In what order do the values log?
  67. Not answered. Errors are thrown, caught, and thrown again along one chain. What logs?
  68. Not answered. A rejection is "handled" by returning null. What logs?
  69. Not answered. An error passes through a try/finally with no catch. What logs?
  70. Not answered. When must a rejection handler be attached to avoid an unhandledrejection event?
  71. Not answered. In what order do the values log?
  72. Not answered. One function throws, the other returns Promise.reject. What logs?
  73. Not answered. queueMicrotask and .then are mixed. In what order do the values log?
  74. Not answered. Microtasks enqueue more microtasks. In what order do the values log?
  75. Not answered. Microtasks keep scheduling more microtasks. In what order do the values log?
  76. Not answered. An async function competes with queueMicrotask. In what order do the values log?
  77. Not answered. Chained .thens interleave with queueMicrotask. What does the final log show?
  78. Not answered. In browsers, what happens to setTimeout(fn, 0) when timers are deeply nested?
  79. Not answered. Two timers with the identical delay. In what order do they fire?
  80. Not answered. A timer is cancelled right after scheduling. What logs?
  81. Not answered. A 10ms timer vs. a 50ms busy-wait. In what order do the values log?
  82. Not answered. What happens with a gigantic delay: setTimeout(fn, 2 ** 31)?
  83. Not answered. A microtask schedules a timer while one is already pending. In what order do the values log?
  84. Not answered. What is the key behavioral difference between setInterval(fn, 100) and a recursive setTimeout(fn, 100)?
  85. Not answered. A for await loop over a synchronous-looking async generator. In what order do the values log?
  86. Not answered. The generator awaits a timer between yields. In what order do the values log?
  87. Not answered. for await over an array of promises with mixed timing. In what order do the values log?
  88. Not answered. What does the next() method of an async iterator return?
  89. Not answered. Sequential awaiting vs Promise.all. Which label logs first?
  90. Not answered. In what order do the values log?
  91. Not answered. A promise-based sleep. In what order do the values log?
  92. Not answered. Microtask yield vs macrotask yield. In what order do the values log?
  93. Not answered. A callback API is wrapped in a promise. In what order do the values log?
  94. Not answered. How many times is flaky called in total?
  95. Not answered. map with an async callback. What logs?
  96. Not answered. Both operations are started before the first await. What logs?
  97. Not answered. After the race is decided, what happens to the slow promise?
  98. Not answered. An in-flight fetch is aborted via AbortController. What happens to its promise?
  99. Not answered. Which statements about async/await are true? (Select all that apply.)
  100. Not answered. The grand finale — every mechanism at once. In what order do the numbers log?