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:
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:
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:
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:
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
constorlet, and keep it inside its braces - Ask a value’s type with
typeof, spot an array withArray.isArray(), and tellnullfromundefined - 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.