Learn / macOS

Learn JavaScript with lessons and practice

Use JavaScript worked examples, drills, and linked challenges to turn a language concept into a skill.

JavaScript lessons with the prerequisite order, worked examples, and drills.
JavaScript lessons with the prerequisite order, worked examples, and drills. Select the image to enlarge.
  1. Choose a concept

    Choose a lesson on scope, closures, arrays, promises, or events. Read the worked example and predict its result before opening the explanation.

    Example

    A function closes over count. Call it twice and predict whether the second call sees the updated count. Explain where that value is stored.

  2. Trace and explain

    For an asynchronous example, write down the synchronous statements and then the queued callbacks. Step through the visualization to check the order.

    Example

    With a log before a resolved promise callback and a log after scheduling it, explain why the two synchronous logs appear first.

  3. Apply it in practice

    Use the linked exercise or open a JavaScript challenge in Coding. Run visible tests and explain which language rule your implementation relies on.

    Example

    Use a map in Two Sum and explain why looking up a missing key differs from retrieving a stored index of zero.

Check your work

You can explain a worked example and use the same rule on a new input or exercise.

Try it yourself

Write a prediction for three log statements. Log A, schedule a resolved promise callback that logs B, then log C. Check your prediction against the worked example for asynchronous execution.

What to look for
The synchronous code logs A and C before the promise callback logs B. Explain when the callback can run even though the promise is already resolved.