Loading video player…

Welcome to the Nightly Backup Check

This course is about how JavaScript declares names and what kinds of values it has: const and let, typeof, null and undefined, empty values, and mixing text with numbers. Values that are missing, empty, or text are where JavaScript quietly carries on, or gives a different answer from Python’s. Along the way, you’ll port Kestrel Print’s Python backup check.

Here’s one of those places, on a new server where nobody set BACKUP_BUCKET. These are the check’s key lines in Python. On that server, the check refuses to start:

Language: Python
import os
import sys

bucket = os.environ.get("BACKUP_BUCKET")
region = os.environ.get("BACKUP_REGION")
mode = "live"
retries = 3

if bucket is None:
    print("No BACKUP_BUCKET set: refusing to start.")
    sys.exit(1)

print(f"Backing up to {bucket} in {region} ({mode})")
print(f"Up to {retries + 1} attempts")
print(f"Debug: bucket is {type(bucket).__name__}")

It prints its refusal and exits with status 1:

Language: Program Output
No BACKUP_BUCKET set: refusing to start.

Here’s the same check ported line by line to JavaScript, with bucket === null where Python says bucket is None:

Language: JavaScript
const bucket = process.env.BACKUP_BUCKET;
const region = process.env.BACKUP_REGION;
const mode = "live";
const retries = 3;

if (bucket === null) {
  console.log("No BACKUP_BUCKET set: refusing to start.");
  process.exit(1);
}

console.log(`Backing up to ${bucket} in ${region} (${mode})`);
console.log(`Up to ${retries + 1} attempts`);
console.log(`Debug: bucket is ${typeof bucket}`);

On the same server, with BACKUP_REGION set to eu-west-2, it prints undefined for the bucket and exits with status 0, as if it succeeded:

Language: Program Output
Backing up to undefined in eu-west-2 (live)
Up to 4 attempts
Debug: bucket is undefined

That undefined is JavaScript’s way of saying that nothing was assigned, and you’ll get to know it well.

That’s Kestrel Print’s old problem: twice, its nightly cron job has “succeeded” in the wrong place, because a setting was missing.

So the check reads five settings (the bucket, the region, the address to notify, a dry-run flag, and the retry count) and refuses to start without a bucket. The servers are being rebuilt to run JavaScript, so you’ll port the check, one kind of line at a time.

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

  • Declare each name once with const or let, and keep it inside its braces
  • Ask a value’s type with typeof, spot an array with Array.isArray(), and tell null from undefined
  • Check for empty values, from empty strings to empty arrays and objects
  • Mix text and numbers safely, converting once with Number() and comparing with ===
  • Port the whole backup check to JavaScript

You need to know Python’s types (int, float, str, bool and None) and how to check them with type() and isinstance(). In JavaScript, you need to know how to write small programs with const, if, functions, arrays, and objects. Any current version of Node.js is fine: the examples use Node 26 and Python 3.15.

The course mixes videos with text lessons and exercises, and every video has a summary below it. A quiz and a summary close the course.

The next video, Declaring Names Once With const and let, starts at the top of the backup check.

Download

Sample Code (.zip)

7.0 KB
Download

Course Slides (.pdf)

1006.4 KB

00:02 Welcome to JavaScript Variables and Types for Pythonistas! It’s about how JavaScript declares names and what kinds of values it has. Missing, empty, or text values are where it quietly carries on or answers differently from Python.

00:18 Kestrel Print, a print shop, is moving to a new server. You’ll port its Python backup check. Here’s a first taste. On the new server, nobody set BACKUP_BUCKET, so the Python check refuses to start.

00:34 In the line-by-line port, this line turns is None into === null. Run it: the port prints backing up to undefined, and exits as if it succeeded.

00:48 undefined means nothing was assigned here, and you’ll get to know it well.

00:54 That’s an old problem at the shop. Twice, the nightly job “succeeded” in the wrong place: a setting was missing. So the check reads five settings. The servers are being rebuilt to run JavaScript, so you’ll port it, one kind of line at a time.

01:14 You’ll declare names with const and let, ask a value’s type with typeof, and tell null and undefined apart.

01:22 You’ll check for empty values and mix text and numbers. The project ports the whole check.

01:30 You need to know Python’s types and type checks, and how to write small JavaScript programs. Any current Node is fine.

01:40 Videos mix with text lessons and exercises, and every video has a summary below it. A quiz and a summary close the course. The next video, Declaring Names Once With const and let, starts at the top of the backup check.

Become a Member to join the conversation.