JavascriptPromises and Async/Await

Promises represent future values in asynchronous code, helping manage sequences of async tasks. Async/await syntax makes asynchronous code look synchronous, simplifying complex chains and improving readability.

const fetchData = () => new Promise(resolve => setTimeout(() => resolve('data'), 1000));

async function getData() {
  const data = await fetchData();
  console.log(data);
}
getData();