Welcome to From Python’s with to JavaScript’s using and try/finally! JavaScript has try and
finally; using and await using are newer. They clean up differently from Python’s
with: where you acquire, how long you hold, what you await. You’ll port a print shop’s
Python job runner.
Here’s a taste. The shop’s other PC already locked job J-314. In Python, a with statement
holds each job’s lock. The JavaScript port uses try and finally instead: in the try block,
it takes the lock, and the finally block releases it. Python skips J-314, leaving the other
PC’s lock. JavaScript says it released J-314’s lock, then skips it. It ends with no error, and
the other PC’s lock is gone. The next lesson shows why.
Priya looks after Inkwell & Co.’s systems. Her runner locks each job, spools its artwork and sends it to a press. It cleans up, even when one fails. It’s joining the shop’s new JavaScript order-tracking app.
By the end of the course, you’ll be able to:
- Clean up with
try/finallyand see what Node closes. - Release a lock with
usingand your own disposables. - Close connections with
await usingand a cleanup stack. - Port the job runner.
You should know Python’s context managers, async ones and ExitStack included. In JavaScript,
you should know classes, async functions, try and catch, and file reads and writes. Use Node 24.2 or later,
for using and import.meta.main. These examples use Node 26 and Python 3.15.
Videos mix with text lessons and exercises. Every video has a summary below it. A quiz and a summary close the course.
Next up: Porting with to try/finally. It starts from this lock.