20 important interview questions on Asynchronous JavaScript

🔥 Async JavaScript – Interview Questions

🟢 Basic Level (1–7)

1. What is Asynchronous JavaScript?

👉 JavaScript that allows tasks to run in the background without blocking the main thread.


2. Difference between synchronous and asynchronous?

  • Synchronous → Executes line by line (blocking)
  • Asynchronous → Executes without waiting (non-blocking)

3. What is setTimeout()?

👉 Runs a function once after a specified delay.


4. What is setInterval()?

👉 Runs a function repeatedly after a fixed interval.


5. What is a callback function?

👉 A function passed as an argument to another function and executed later.


6. What is callback hell?

👉 Nested callbacks that make code unreadable and hard to maintain.


7. Is JavaScript synchronous or asynchronous?

👉 Single-threaded but supports asynchronous behavior via event loop + Web APIs.


🟡 Intermediate Level (8–14)

8. What is a Promise?

👉 An object representing the eventual completion or failure of an async operation.


9. What are Promise states?

  • Pending
  • Fulfilled (Resolved)
  • Rejected

10. Difference between .then() and .catch()?

  • .then() → handles success
  • .catch() → handles errors

11. What is finally() in Promise?

👉 Runs after success or failure (cleanup code).


12. What is async/await?

👉 A cleaner way to handle Promises using synchronous-like syntax.


13. Can we use await without async?

👉 ❌ No, only inside async functions.


14. What happens if a Promise is rejected and not handled?

👉 It throws an Unhandled Promise Rejection error.


🔵 Advanced Level (15–20)

15. What is the Event Loop?

👉 It manages execution of asynchronous code (handles call stack + callback queue).


16. What is the Call Stack?

👉 A stack where JS executes function calls.


17. What is the difference between microtask and macrotask?

  • Microtask → Promise callbacks, queueMicrotask
  • Macrotask → setTimeout, setInterval, DOM events

👉 Microtasks execute first.


18. Output-based Question:

console.log("A");setTimeout(() => console.log("B"), 0);Promise.resolve().then(() => console.log("C"));console.log("D");

👉 Output:

A
D
C
B

19. What is Promise.all()?

👉 Runs multiple promises in parallel and resolves when all succeed.


20. Difference between Promise.all() and Promise.race()?

  • Promise.all() → waits for all
  • Promise.race() → returns first completed promise

💡 Bonus Tip (Important for Interviews)

👉 Most asked topics:

  • Event Loop
  • Promise vs async/await
  • Output questions
  • Error handling