Loading video player…

Welcome to Riverside Pool's Passes

This course shows you how to write JavaScript classes: constructors, fields, private state, static members, subclasses, and instances you print, copy, and hand to callbacks.

Your project is to port the Python module behind a city pool’s passes. Here’s a first taste. The pool’s Python Pass class checks Priya in for her first swim:

Language: Python
class Pass:
    def __init__(self, holder):
        self.holder = holder
        self.swims = 0

    def check_in(self):
        self.swims += 1
        return f"{self.holder} checked in, swim {self.swims}"

priya = Pass("Priya Nair")
print(priya.check_in())

It prints her first check-in:

Language: Program Output
Priya Nair checked in, swim 1

Say you port it to JavaScript line by line, as pool-passes.js:

Language: JavaScript
class Pass {
  constructor(self, holder) {
    self.holder = holder;
    self.swims = 0;
  }

  checkIn(self) {
    self.swims += 1;
    return `${self.holder} checked in, swim ${self.swims}`;
  }
}

const priya = Pass("Priya Nair");
console.log(priya.checkIn());

When you run it with node pool-passes.js, it stops on line 13, the call that makes Priya’s pass (Node’s source line and stack trace are left out here):

Language: Program Output
TypeError: Class constructor Pass cannot be invoked without 'new'

The call itself raises the TypeError: the class constructor Pass can’t be invoked without new. In Python, calling the class made the pass. JavaScript refuses the call, and Priya never checks in. A line-by-line port looks right, and where it breaks is what Python’s classes did for you. That’s the first break the course walks you through.

Riverside Pool’s swimmers buy casual swims, ten-swim cards (£45 for ten swims) or monthly memberships, and its early-morning lane swim, Early Lanes, has only two lanes. Booking is moving online, to JavaScript, so you’ll port the pool’s booking module.

By the end of this course, you’ll be able to:

  • Port a class to constructor and this, and a dataclass to fields and a constructor
  • Keep state private in # fields behind get and set, and share prices and factories with static
  • Extend a class with extends and super(), and print instances with toString()
  • Copy instances with their class, and pass methods as callbacks without losing this
  • Port the whole pool passes module to JavaScript

You only need to know how to write Python classes with __init__ and methods, @property, @classmethod and @staticmethod, inheritance with super(), and dataclasses. In JavaScript, you only need to know how to write functions, arrow functions, callbacks and options objects, how to copy data with structuredClone() and JSON, and how to throw errors.

A current version of Node.js and of Python is fine: the examples use Node 26 and Python 3.15.

The course mixes short videos and text lessons, with exercises where you write the code yourself. Every video has a summary below it, and a quiz and a summary close the course.

Next up: Porting a Class to constructor and this, a text lesson that opens on the Pass class.

Download

Sample Code (.zip)

12.2 KB
Download

Course Slides (.pdf)

1.0 MB

Become a Member to join the conversation.