JavaScript Institute Asynchronous Programming Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Thames
T
Thames
Community Contributor
Quizzes Created: 11982 | Total Attempts: 187,298
| Attempts: 14 | Questions: 20 | Updated: Aug 15, 2026
Please wait...
Question 1 / 21
🏆 Rank #-- ▾
0 %
0/100
Score 0/100

1. The await keyword can only be used inside an async function. True or False?

Explanation

Within ordinary JavaScript function bodies, `await` can be used only in functions declared `async`. It pauses execution until the awaited promise settles. Modern JavaScript also allows top-level `await` in modules, but that exception is outside the basic rule assumed by this question.

Submit
Please wait...
About This Quiz
JavaScript Institute Asynchronous Programming Quiz - Quiz

This quiz evaluates your understanding of asynchronous programming in JavaScript, covering callbacks, promises, async\/await, event loops, and concurrency patterns. Master these essential concepts to write efficient, non-blocking code and handle real-world async operations effectively.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Which statement best describes the relationship between callbacks and Promises?

Explanation

Promises and callbacks both handle asynchronous operations, but Promises offer a more structured approach. They support chaining with `.then()` and centralized error handling with `.catch()`, which can make complex asynchronous code easier to read and maintain than deeply nested callbacks.

Submit

3. A rejected Promise that has no .catch() handler will cause an unhandled rejection error. True or False?

Explanation

A rejected Promise with no rejection handler, such as `.catch()`, leaves the rejection unhandled. JavaScript runtimes typically report it as an unhandled Promise rejection, often through a console warning or error. The exact behavior depends on the environment, but attaching a handler allows the rejection to be processed and prevents the unhandled-rejection report.

Submit

4. What is the difference between Promise.all() and Promise.allSettled()?

Explanation

Promise.all() rejects as soon as one input promise rejects, so it does not return results for all inputs. Promise.allSettled() waits until every promise has either fulfilled or rejected, then returns each outcome, including its status and value or reason.

Submit

5. Macrotasks in the event loop include setTimeout and setInterval. True or False?

Explanation

`setTimeout` and `setInterval` schedule callbacks as timer tasks, which are handled as macrotasks by the event loop after the current synchronous code and microtasks have run.

Submit

6. What is the purpose of the try/catch block in async functions?

Explanation

A try/catch block lets an async function respond to errors raised by awaited operations, such as a rejected promise. The catch block can handle the error or provide a fallback, preventing it from becoming an unhandled rejection.

Submit

7. Promise.race() returns the result of whichever promise resolves or rejects first. True or False?

Explanation

Promise.race() returns a promise that settles as soon as the first input promise settles. If that promise fulfills, the returned promise fulfills with its value; if it rejects, the returned promise rejects with its reason. Other promises continue running, but their later outcomes do not change the result. So the statement is true.

Submit

8. What is the primary purpose of asynchronous programming in JavaScript?

Explanation

Asynchronous programming lets JavaScript continue running other tasks while waiting for operations such as network requests or file access to finish. This keeps the main thread responsive rather than blocked, improving the experience in applications and web pages.

Submit

9. An async function always returns a ____.

Explanation

An async function always returns a Promise. Any value returned from the function becomes the Promise’s fulfillment value, while an error thrown inside it causes the Promise to reject.

Submit

10. Which method is used to handle errors in a Promise chain?

Explanation

In JavaScript, `.catch()` handles a Promise chain’s rejection, including errors thrown by earlier `.then()` callbacks. It receives the rejection reason, allowing you to log or manage the error, or recover by returning a value or another Promise. The other listed methods are not standard Promise methods for handling errors.

Submit

11. The .then() method on a Promise returns another Promise. True or False?

Explanation

True. The `.then()` method always returns a new Promise, allowing asynchronous operations to be chained. That Promise settles based on the value returned by the callback: it fulfills with a regular value, adopts the state of a returned Promise, or rejects if the callback throws an error.

Submit

12. A Promise can be in one of three states. Which of the following is NOT a Promise state?

Explanation

A Promise has three states: pending while its outcome is undecided, fulfilled when it succeeds, and rejected when it fails. “Paused” is not a Promise state.

Submit

13. What is callback hell (or pyramid of doom)?

Explanation

Callback hell, also called the pyramid of doom, occurs when asynchronous operations are written as deeply nested callbacks. This nesting makes code harder to read, understand, debug, and maintain. Splitting operations into smaller functions or using promises and async/await can help avoid it.

Submit

14. A callback function is passed as an argument to another function. True or False?

Explanation

A callback is a function passed as an argument to another function so it can be called later, often after an operation finishes or an event occurs.

Submit

15. What does the event loop do in JavaScript?

Explanation

The event loop coordinates synchronous and asynchronous execution. It checks whether the call stack is empty and, when it is, moves eligible queued tasks onto the stack to run. This lets JavaScript handle asynchronous operations while executing code on a single main thread.

Submit

16. Which of the following is NOT a way to handle asynchronous operations in JavaScript?

Explanation

Callbacks, Promises, and async/await are standard JavaScript patterns for coordinating work that completes later without blocking the main thread. Synchronous loops execute instructions immediately, one after another, and can block the event loop while running. They do not provide a mechanism for waiting on or coordinating asynchronous results, so they are not an asynchronous-handling approach.

Submit

17. What does async/await syntax do?

Explanation

Async/await provides a clearer way to write asynchronous operations. It lets code pause while waiting for a promise to settle, then continue in a readable, sequential style, without blocking the event loop or automatically running tasks in parallel.

Submit

18. What does Promise.all() do?

Explanation

`Promise.all()` takes an iterable of promises and returns a promise that fulfills with an array of their results once every promise fulfills. The results appear in the same order as the input promises. If any promise rejects, the returned promise rejects immediately with that reason.

Submit

19. Microtasks include Promises and ____ functions.

Explanation

Microtasks include Promise callbacks and functions scheduled with `queueMicrotask()`. Once the current JavaScript task finishes, the event loop processes the microtask queue before starting the next task, such as a timer callback.

Submit

20. Async/await syntax was introduced to JavaScript in ES____.

Explanation

Async/await became part of the JavaScript language standard with ECMAScript 2017 (ES8). It provides a clearer way to write asynchronous code, allowing developers to use `await` within an `async` function instead of chaining promises directly.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
The await keyword can only be used inside an async function. True or...
Which statement best describes the relationship between callbacks and...
A rejected Promise that has no .catch() handler will cause an...
What is the difference between Promise.all() and Promise.allSettled()?
Macrotasks in the event loop include setTimeout and setInterval. True...
What is the purpose of the try/catch block in async functions?
Promise.race() returns the result of whichever promise resolves or...
What is the primary purpose of asynchronous programming in JavaScript?
An async function always returns a ____.
Which method is used to handle errors in a Promise chain?
The .then() method on a Promise returns another Promise. True or...
A Promise can be in one of three states. Which of the following is NOT...
What is callback hell (or pyramid of doom)?
A callback function is passed as an argument to another function. True...
What does the event loop do in JavaScript?
Which of the following is NOT a way to handle asynchronous operations...
What does async/await syntax do?
What does Promise.all() do?
Microtasks include Promises and ____ functions.
Async/await syntax was introduced to JavaScript in ES____.
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!