JavaScript Notes
Master JavaScript Promise interview questions with detailed answers. Covers Promise states, chaining, Promise.all/race/allSettled/any, async/await, error handling, and output questions.
Promises are the backbone of async JavaScript. Every interview from mid-level to senior level includes at least 3-5 Promise questions. This guide covers all of them with detailed answers.
Tips for Interview 💡
- Always mention the 3 states: pending, fulfilled, rejected.
- Know the difference between
Promise.all,Promise.allSettled,Promise.race,Promise.any. - Explain that
async/awaitis syntactic sugar over Promises. - Promise executor runs synchronously;
.thencallbacks run as microtasks. - Unhandled promise rejections cause process crashes in Node.js.
Q1: Create a Basic Promise
Executing... Executing... Resolved: Success! Error: Network failed!
Q2: Promise Chaining
Step 1 done Got: Step 1 Step 2 done Got: Step 2 Final: Final
Q3: What is the Output? (Tricky)
A D E Then: B
Key Points:
- Executor runs synchronously → A, D print immediately.
- Once
resolve("B")is called, promise is settled →reject("C")is ignored. "E"prints before.then(microtask).
Q4: Promise.all — All must succeed
All resolved: ["User data", "Product data", "Order data"]
With failure:
Failed: Error!
Q5: Promise.allSettled — Don't fail on rejection
✅ Success ❌ Failure ✅ Another success
Use case: When you want results from ALL promises, regardless of failure.
Q6: Promise.race — First to settle wins
Winner: fast
Use case: Timeout patterns — race a fetch with a timeout promise.
Q7: Promise.any — First to FULFILL wins (ignores rejections)
First success: First success
If ALL reject:
true ["E1", "E2", "E3"]
Q8: Comparison Table
| Method | Behavior | Short-circuit |
|---|---|---|
Promise.all | All must fulfill | On first rejection |
Promise.allSettled | Wait for all to settle | Never |
Promise.race | First to settle (fulfill or reject) | On first settlement |
Promise.any | First to fulfill | On first fulfillment |
Q9: Error Handling Chain
start Caught: Something broke After recovery: recovered
Rule: Once an error is thrown in a chain, it skips all .then until the nearest .catch. After .catch returns, the chain continues normally.
Q10: .finally()
Data: data Loading done: false Final: data
Note: .finally() does NOT modify the resolved value — it passes through.
Q11: async/await Syntax
Q12: async/await Error Handling
Q13: Sequential vs Parallel Promises
sequential: ~300ms parallel: ~100ms
Q14: Promisify Callback
file contents
Q15: Output — Promise in if/else
After if/else Result: heads (or tails — random)
Q16: Async Function Always Returns Promise
Promise {<fulfilled>: 42}
42Q17: await with non-Promise values
async function test() {
const a = await 42; // Wraps in Promise.resolve(42)
const b = await "hello"; // Wraps in Promise.resolve("hello")
console.log(a, b);
}
test();42 hello
Q18: Chained async/await
async function step1() { return "Step 1"; }
async function step2(val) { return val + " → Step 2"; }
async function step3(val) { return val + " → Step 3"; }
async function run() {
const result = await step3(await step2(await step1()));
console.log(result);
}
run();Step 1 → Step 2 → Step 3
Common Traps 🪤
| Trap | Issue | Fix |
|---|---|---|
Missing await | Promise returned, not value | Always await async calls |
await in .forEach | Doesn't wait | Use for...of with await |
| Unhandled rejection | Silent crash in Node.js | Always .catch() or try/catch |
Promise.all short-circuits | One rejection kills all | Use Promise.allSettled instead |
| Not returning in chain | Returns undefined | Always return from .then |
The forEach Trap:
Interview Quick Reference
Promise.resolve(val) → Already fulfilled
Promise.reject(err) → Already rejected
new Promise(fn) → fn runs synchronously
.then(onFulfilled) → Runs as microtask
.catch(onRejected) → Same as .then(null, onRejected)
.finally(fn) → Runs always, passes through value
async fn() { ... } → Returns a Promise
await expr → Pauses async fn, schedules resume as microtaskPractice Questions
- Implement
sleep(ms)that returns a Promise resolving aftermsmilliseconds. - Write
timeout(promise, ms)that rejects if promise takes longer thanms. - Build
promiseQueue(tasks, concurrency)— run N tasks at a time. - Implement a simple
Promiseclass from scratch (constructor, then, catch). - Refactor callback hell to async/await with proper error handling.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Top 30 JavaScript Promise Interview Questions & Answers 2026.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this JavaScript Master Course topic.
Search Terms
javascript-complete-guide, javascript master course, javascript, complete, guide, interview, promise, questions
Related JavaScript Master Course Topics