0Pricing
JavaScript Academy · Lesson

Writing async functions; try/catch; parallel vs sequential

Create async functions, await results, catch errors, and compare sequential vs parallel patterns.

Intro to async/await

Goal: Use async/await safely.

  • Create async functions
  • Await values
  • try/catch errors
  • Parallel vs sequential
Writing async functions; try/catch; parallel vs sequential — illustration 1

Tiny Promise helper

Create a tiny Promise-based helper to test awaits.

// delay returns a Promise that resolves after ms
function delay(ms, value) {
  return new Promise(function (resolve) {
    setTimeout(function () { resolve(value); }, ms);
  });
}

// Example usage
delay(10, "ok").then(function (v) {
  console.log("delay:", v);
});
Writing async functions; try/catch; parallel vs sequential — illustration 2

All lessons in this course

  1. Writing async functions; try/catch; parallel vs sequential
  2. Timeouts & Aborting with AbortController
  3. Retrying & Backoff Patterns
← Back to JavaScript Academy