JavaScript · Intermediate level

Intermediate level · Module 2 of 6 · 16 guided hours

Asynchronous JavaScript

Understand the event loop and write asynchronous code with callbacks, promises and async/await, handling errors correctly.

Learning objectives

  • Explain the event loop, tasks and microtasks
  • Create and combine promises
  • Write async/await code with proper error handling

Topics

  • single thread and the event loop
  • callbacks and setTimeout
  • promises: then, catch, finally
  • Promise.all, allSettled, race
  • async/await
  • try/catch with async code

Lessons

  1. Lesson 1 The Event Loop

    Understand how JavaScript runs asynchronous code on one thread with a call stack, task queue and microtask queue.

    single-threadedcall stacktask queue (setTimeout)microtask queue (promises)

  2. Lesson 2 Promises

    Create and consume promises, chain them, handle errors and combine several promises.

    promise statesthen / catch / finallyPromise.allPromise.allSettled

  3. Lesson 3 async/await and Error Handling

    Write asynchronous code that reads like synchronous code with async/await, handle errors with try/catch and run independent work in parallel.

    async functionawaittry/catch/finallyunhandled rejection

Practical activity

Simulate loading data from three slow sources with promises, show progress, combine the results and handle one source failing.

Expected outcomes

  • Correct asynchronous code
  • No unhandled promise rejections

Assessment

Practical: predict the output order of an asynchronous script, then fix a buggy async function so it handles failures and runs requests in parallel.

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.