4321 is Astro

Astro’s default port is 4321. Like Vite, this project is trying to convey its (rocket-launch) branding, even in this small detail. ...

July 21, 2026 · 1 min · Jake Worth

Node's Timeout _destroyed Private Method

Node Timeout timers have a private boolean attribute called _destroyed. It tells you if the function has been cleared: timer._destroyed; ...

July 20, 2026 · 1 min · Jake Worth

Uncheck Buttons With JavaScript

Today I used JavaScript to mass-unsubscribe from a website’s email notifications. Here’s the code, followed by what I did and why. document .querySelectorAll('[role="switch"]') .forEach((element) => element.click()); ...

July 20, 2026 · 1 min · Jake Worth

JavaScript Reflection with toString

Reflection is an important tool in programming; it lets us examine a language’s structure. Can we reflect in JavaScript? Sort of. Some functions can be reflected with toString(): const one = () => 1; // undefined one.toString(); // '() => 1' Very cool! But native functions only return this: > Math.max.toString() 'function max() { [native code] }' You must read the ECMAScript specification to know what the function is required to do. The actual implementation is written in the JavaScript engine, which for Node is Torque, which is why Node can’t show it via toString().

July 10, 2026 · 1 min · Jake Worth

Focus a JS Test

A vital testing skill is focusing a test. When iterating on a failing test, we want that test under microscope. The way I do this in JavaScript is .only: import {describe, expect, test} from 'vitest'; import {sum} from './sum.js'; test('adds 1 + 2 to equal 3', () => { expect(sum(1, 2)).toBe(3); }); describe.only('adding fours', () => { test('adds 4 + 4 to equal 8', () => { expect(sum(4, 4)).toBe(8); }); }); ...

July 10, 2026 · 1 min · Jake Worth

JSDoc Deprecations in TypeScript

JSDoc has a @deprecated tag that you can use in TypeScript, too. Here’s an example. ...

July 10, 2026 · 1 min · Jake Worth

NPM List Packages

When upgrading a dependency for a security issue, we might upgrade and move on: npm install <dependency>@<version> But wait! Was every <dependency> version upgraded, or just the version in package.json? Check with: npm list // or npm ls ...

July 7, 2026 · 1 min · Jake Worth

Node REPL, No Preview

After version v12.17.0, Node’s REPL provides a useful preview effect. In this example, 2 is shown in gray before I hit enter. > 1 + 1 2 But what if I don’t want that? Here’s a file called repl that disables it as an option: #!/usr/bin/env node const repl = require('node:repl'); repl.start({preview: false}); Then: $ ./repl > 1 + 1 No preview. Docs

June 2, 2026 · 1 min · Jake Worth

NVM Install and Use Latest LTS

With my Node versions managed via NVM, I want to be on the latest LTS. You can ensure that happens with these commands: $ nvm install --lts $ nvm alias default lts/* default -> node (-> v24.16.0) ...

May 29, 2026 · 1 min · Jake Worth

JavaScript Wraparound Index

What I call “wraparound” are repeatable indices on an array. The common use case is a carousel. Here’s how it’s done: const items = ['first', 'middle', 'last']; const i = 0; // Our iterable index // "Next" -> const nextIndex = (i + 1) % items.length; // <- "Previous" const prevIndex = (i - 1 + items.length) % items.length;

May 7, 2026 · 1 min · Jake Worth