Programming foundations

Stage 1 · Lesson 10 of 10

Promises and async/await, a first look

Your first language

JavaScript runs your code on one thread, one step at a time. It does not wait for slow work such as a timer, a network request or reading a file with node:fs/promises. Instead it hands back a , a value that will be ready later, and carries on.

async and await let you write this as if it ran in order, such as const text = await readFile("data.json", "utf8") inside an async . is the part of JavaScript that runs your code again when the slow work finishes.

That is why console.log output can appear in a surprising order. readFileSync is enough for this stage, but you will need this the moment you call an .

Common trapforgetting await and holding a Promise instead of the data.

A question to check yourself, an AI practice session and 2 cheat sheet entries come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

  • CoursePaid
    Grokking JavaScript Fundamentals

    Design Gurus · Beginner · $50

    The language itself, closures and async included, with runnable exercises per lesson

  • GuideFree
    JavaScript.info

    Ilya Kantor

    Free: Part 1 is the most complete modern JavaScript tutorial, with tasks per chapter

Practise

  • Small exercises in your language track, with free feedback from a human mentor

  • Foundations path: the JavaScript basics lessons and the exercises repo with tests

Keep handy

  • The JavaScript reference: look up every array and string method here

Mark this stage as not done?