Skip to content

JS workshop

The JS workshop holds the JavaScript the course assumes, in ten units. Every unit explains a topic briefly, shows it with examples from Lorraine Commons and ends with exercises at three levels with solutions.

You can work through the units in order or only through the ones the entry test recommends. When a chapter assumes a topic, it points you to the matching unit.

Below every example there is a "Run" button. The program then runs right in the browser, and its output appears below the code. "Edit" lets you change the code and run it again, and "Reset" restores the original. Predict what a program prints first, and only then check.

The examples of the unit "The DOM and events" are small HTML pages. They appear in a frame below the code, with the console output underneath.

All examples are also in the course repo under examples/js, one folder per unit. There you run them with Node.js.

Terminal window
cd examples/js/variables/en
node types.mjs
UnitContentsNeeded in the course
Variables, types and operatorslet and const, primitive types, comparisons, what counts as true and false, ??everywhere
Control flowif and else, the conditional operator, switch, loops with for...of and while, break and continueeverywhere
Functions and scopefunctions and arrow functions, default values, scope, closuresfrom part 1, composables in part 5
Objects and arraysobjects, arrays, references, spread, destructuring, optional chainingfrom part 1
Strings and template literalstemplate literals, string methods, search that ignores case, sortingsearch and filter from part 3
Classes and thisclasses, private fields, getters, static methods, this and binderror classes of your own, reading code with this
Handling errorsthrow, try, catch and finally, error types, error classes of your owndata from the server in part 1 and part 7
The DOM and eventsfinding and creating elements, events, event delegation, formsthe SPA built by hand in part 2
JSON and data formatsJSON.stringify and JSON.parse, dates, copies with structuredClonedata from the server, saving in the browser
Formatting numbers and datesamounts in francs, date and time, time zones with Intlwherever the app shows amounts and dates

Anything beyond these basics is in part 1, such as modules, values and references in detail, map, filter and reduce, and asynchronous JavaScript with fetch.

Text and figures are licensed under CC BY-SA 4.0, the code under the MIT License and the course data under CC0 1.0. The figures use the font Kalam under the SIL Open Font License 1.1. The sources are on GitHub.