Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
JavaScript 10 questions

Promises and Async/Await

Master asynchronous flow in JavaScript. Understand states, chaining promises, async-await keywords, error propagation, and Promise.all.

More JavaScript
Interview questions 1–10 of 10
1

What is a Promise in JavaScript and what states can it have?

A Promise is an object representing the eventual completion or failure of an asynchronous operation. It acts a...

Read answer →
2

How do .then(), .catch(), and .finally() work in Promise chains?

These methods let you handle a promise's eventual result. Each returns a new Promise, which is what enables ch...

Read answer →
3

How does async/await simplify working with Promises?

async/await is syntactic sugar over Promises that lets asynchronous code be written and read like synchronous...

Read answer →
4

How do you handle errors with async/await?

Errors in async/await are handled with standard try/catch blocks, unlike Promise chains which use .catch(). A...

Read answer →
5

What is the difference between Promise.all(), Promise.race(), Promise.allSettled(), and Promise.any()?

MethodResolves whenRejects whenPromise.all()All promises fulfillAny one rejects (fails fast)Promise.race()Firs...

Read answer →
6

How do you run asynchronous operations in parallel vs sequentially using async/await?

Using await one after another runs operations sequentially (each waits for the previous). Starting all promise...

Read answer →
7

What is a microtask and how do Promises relate to the event loop?

Promise callbacks (.then, .catch, .finally, and code after await) are queued as microtasks, which run after th...

Read answer →
8

How do you convert a callback-based function into a Promise-based one?

Wrapping a callback-style function in a new Promise, calling resolve on success and reject on error, is called...

Read answer →
9

Can you use await inside a regular for loop and a forEach loop? What's the difference?

await works correctly inside a regular for loop because the loop itself is inside an async function's synchron...

Read answer →
10

What are common mistakes developers make with Promises and async/await?

MistakeProblemFixForgetting to return a promise in a chainNext .then() gets undefined instead of resolved valu...

Read answer →