Editing in Nodes REPL Editor

The Node REPL has its own editor: node > .editor // Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel) const increment = (array) => array.map(item => item + 1) increment([1,2,3]) Exit and evaluate with Ctrl+D: [ 2, 3, 4 ] I’d use this to experiment with JavaScript API’s without leaving my terminal-based IDE.

July 22, 2025 · 1 min · Jake Worth

Why I'm "All In" on TypeScript

I’ve added TypeScript to several projects I’ve worked on. In this post, I’d like to discuss why I think TypeScript is essential and document my expectations around it. ...

March 26, 2025 · 4 min · Jake Worth

Load a Dependency in the Node REPL

Exploring your JS dependencies locally is a great way to learn and experiment. Here’s how to load a dependency from your /node_modules directory into the Node REPL. $ node > cn = require('classnames') > cn("always", { never: false, sometimes: true }) 'always sometimes'

July 11, 2024 · 1 min · Jake Worth

Absolute Imports in TypeScript and React: A Practical Guide

Absolute imports are an essential developer experience feature for me in any JavaScript application. In this post, I’ll explain what they are, how to use them, and why they matter. ...

May 2, 2023 · 3 min · Jake Worth

Sorting Numbers with JavaScript's sort Function

Today in “Let JavaScript Surprise You”: let array = [1, 20, 11, 10, 7, 17, 2]; console.log(array.sort()); > [1, 10, 11, 17, 2, 20, 7] 😳 The numbers are not sorted as we might expect. What’s going on here? From Mozilla’s docs: The default sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values. Now this sorting makes sense! Luckily, sort accepts a function, so here’s the sorting we intended: const sortNumbers = (first, second) => first - second console.log(array.sort(sortNumbers)) > [1, 2, 7, 10, 11, 17, 20]

February 10, 2023 · 1 min · Jake Worth

How to Create a Timer or Polling in React with setInterval

Have you ever wanted to create a timer in a React app? This could be in support of a UI timer or polling. In this post, I’ll explain how to create a timer effect in a React application using hooks and setInterval. ...

December 29, 2022 · 4 min · Jake Worth

Build a Sentence from a JavaScript Array

Have you ever wanted to take a JavaScript array of strings and turn them into a sentence? Here’s how you do that. const toLearn = [ 'object-oriented programming', 'frontend engineering', 'testing', ] const sentence = new Intl.ListFormat().format(toLearn) > "object-oriented programming, frontend engineering, and testing" ListFormat takes options. This has cross-browser support! The days of building a ’to sentence’ function in JavaScript are over.

December 22, 2022 · 1 min · Jake Worth

Logging an Object in JavaScript

When printing a JavaScript value to the console, I suggest using an object literal over the raw value. ...

July 7, 2022 · 3 min · Jake Worth

Only One Way Out of a Function

A programming style I try to practice could be described as: “there should be only one way out of a function.” Early returns can often cause more confusion than they’re worth. When possible, I avoid them in favor of a single return. ...

May 2, 2022 · 5 min · Jake Worth

How to Organize JavaScript Imports

The import statements at the top of a JavaScript component file can be a confusing, duplicative, churning mess. Is there a way to organize them that makes sense and scales? In this post, I’d like to share the way I handle this detail. ...

August 30, 2021 · 2 min · Jake Worth