🟒 EasyAsync JSπŸ“– Theory Question

Explain Promises β€” states, chaining, and error handling.

πŸ’‘

Hint

pending β†’ fulfilled/rejected; .then chains; .catch handles errors

Full Answer

A Promise is a value that may be available now or later. States: pending β†’ fulfilled / rejected. Once settled, immutable.

fetch('/api/data')
  .then(res => res.json())
  .then(data => console.log(data))
  .catch(err => console.error(err))
  .finally(() => setLoading(false));

Combinators: Promise.all (all must resolve), Promise.allSettled (wait all), Promise.race (first settles), Promise.any (first resolves).

More Async JS Questions

🟒 EasyHow does async/await work under the hood?β†’πŸŸ’ EasyWhat is callback hell and how do you avoid it?β†’πŸŸ’ EasyWhat are Promise combinators and when do you use each?β†’πŸŸ’ EasyWhat is queueMicrotask() and when should you use it?β†’

Practice this in a timed sprint β†’

5 free questions, no signup required

⚑ Start Sprint