How do promises work, and why are they used?

Promises handle asynchronous operations, representing a value that may be resolved or rejected. They improve code readability over callback functions.

let promise = new Promise((resolve, reject) => {
  setTimeout(() => resolve("done"), 1000);
});
promise.then(result => console.log(result));