Porting Python's Defaults and match Statements to JavaScript

Stephen Gruppetta 15 Lessons 2h 32m Updated intermediate js py

Python’s or and its None checks map onto two JavaScript operators that disagree about 0, "", and empty lists. Port r["rooms"] or [DEFAULT_ROOM] as r.rooms || [DEFAULT_ROOM], and a booking with no room ticked comes out with no room and a $0.00 hire fee, because an empty array is truthy in JavaScript.

In this course, you’ll port a volunteer bookings coordinator’s Python script that fills in, prices, and confirms the week’s room requests.

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

  • Pick a value with || and &&, and choose between || and ?? for a default
  • Fill in missing values with ??=, ||=, and &&=
  • Port a match statement with guards or patterns that switch can’t express
  • Call a function only when there is one with ?.()
  • Port the whole booking confirmations script

You’ll need Python’s or, and, conditional expressions, and match. You’ll also need Node 26 and JavaScript programs with objects, Maps, arrays of objects, and arrow functions, plus ??, ?., else if, the conditional operator, and switch. The Python examples use Python 3.15.

The course mixes short videos and text lessons with exercises, a project that ports the whole script, and a quiz.

What’s Included:

  • 15 Lessons
  • Video Subtitles and Full Transcripts
  • Translated Subtitles in 8 Languages
  • 2 Downloadable Resources
  • Interactive Quiz to Check Your Progress
  • 5 Hands-On Coding Exercises
  • Q&A With JavaScript Experts: Ask a Question
  • Certificate of Completion

Downloadable Resources:

Related Learning Paths:

About Stephen Gruppetta

Stephen obtained a PhD in physics and worked as a physicist in academia for over a decade before becoming a programming educator. He's constantly looking for simple ways to explain complex things.

» More about Stephen

← Browse All Courses