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

JavaScript String Concatenation

Here’s a periodic reminder that JavaScript supports string concatenation with a plus sign: > 'foo' + 'bar' 'foobar' ...

May 6, 2026 · 1 min · Jake Worth

JavaScript Spread a String Into An Array

Need an array of letters? Here’s a trick: > const alpha = [...'abcdefghijklmnopqrstuvwxyz'] ...

May 5, 2026 · 1 min · Jake Worth

JavaScript Array Join Comma Default Separator

When you join an array in JavaScript, the default separator is a comma: node> ['j', 'a', 'k', 'e'].join() 'j,a,k,e' ...

May 5, 2026 · 1 min · Jake Worth

JavaScript Bitwise AND

The JavaScript bitwise AND operator (&) can be used for some real-world tasks, like testing if a number is odd or even. ...

May 1, 2026 · 1 min · Jake Worth

Initialize With npm init

Most JavaScript projects come with a package.json. But what if you want to make a new one? ...

February 12, 2026 · 1 min · Jake Worth

Writing the DOM with fs

How can I output the entire DOM to a file in a JavaScript test? ...

January 30, 2026 · 1 min · Jake Worth

Rebuilds on Write With Nodemon

I’ve been hacking on a TypeScript file all day, but I need transpiled JavaScript for any testing. How did I reduce cycle time (and mitigate many chances to forget to build at all)? ...

December 30, 2025 · 1 min · Jake Worth

npmrc "engine-strict"

Suppose your package.json specifies a Node engine of greater than or equal 24. Does this mean all engineers on your team will use Node 24? No, unless you use this one weird trick! ...

December 16, 2025 · 1 min · Jake Worth

Learning JavaScript Promises the Feynman Way

Want to learn a tricky topic and sharpen your learning skills at the same time? In this post, I’ll use the Feynman Learning Technique— a method of learning complex things by explaining them simply— with a sprinkle of LLM magic, to deepen my understanding of JavaScript promises. ...

August 25, 2025 · 7 min · Jake Worth