JavaScriptIntermediate#async#promises

What is a Promise and what are its states?

A Promise is an object representing the eventual result of an async operation, in state pending, fulfilled or rejected. It settles once and then notifies then/catch/finally handlers.

Example
const p = new Promise((resolve, reject) => {
  setTimeout(() => resolve('done'), 100);
});
p.then(v => console.log(v)).catch(console.error).finally(() => console.log('cleanup'));

Related Questions

1
JavaScriptAdvanced#async#promises

Difference between Promise.all, allSettled, race and any?

Open
2
JavaScriptIntermediate#async

How does async/await work?

Open
3
JavaScriptIntermediate#async#performance

How do you run async calls in parallel with async/await?

Open