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