Skip to content
techsnow

Async JavaScript

Promises

A Promise represents a value that will arrive later, like an order receipt. It is either pending, fulfilled (success) or rejected (error).

const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

wait(1000)
  .then(() => console.log("1 second passed"))
  .catch((err) => console.error(err));