I take a look at JavaScript’s reduce() method, walking through how the accumulator works with examples like summing and finding the maximum in an array, and explaining why reduce counts as a “functional” array method...
A look at Node’s built-in test runner from my perspective as a long-time Mocha and Chai user, showing how to write and run basic tests with node:test and node:assert. Coming from Mocha requires few changes, though test files need to live in a test directory to be picked up. I weigh the convenience of a bundled runner against lock-in to a particular runtime...
I walk through publishing my own JavaScript utility to npm so it can be installed and updated like any other package, rather than copying source files between Node projects. I cover creating an npm account, scoping the package name to my username, writing and publishing the code with npm publish, and installing it in another project, using a simple is-even example...
I walk through building user authentication in an Express.js app from the ground up, starting with how HTTP requests, cookies, and sessions work before moving to session IDs and the express-session library. I then cover a login flow with bcrypt-hashed passwords and file-based session persistence, laying groundwork for a future post that will use Passport.js...
In this tutorial, I build a user login and session management system from scratch in Node and Express, starting with a simple cookie-based session counter and progressively adding file-based persistence, user accounts, logout, and password authentication using bcrypt. I also cover input sanitisation, secure cookies, and enforcing HTTPS behind an NGINX proxy. The tutorial is aimed at readers with basic familiarity with Node and Express...
This is a write-up of an exercise from Mosh’s React 18 course: building a small expense-tracking app in React and TypeScript, with Zod used for form validation. I cover component breakdown decisions, persisting expenses to local storage, tradeoffs in TypeScript type definitions, and refactoring repeated table markup into reusable components...
I take a look at copying objects in JavaScript for React state updates, covering why simple assignment fails, how the spread operator creates copies, and how to selectively replace properties during a copy. I also show why shallow copies fall short with nested data, demonstrating how to manually spread nested arrays for add and remove operations, and end by noting how the approach gets messy at deeper nesting levels...
An introduction to htmx and the hypermedia and HATEOAS concepts behind it, followed by a conversion of a simple todo app from a Node/Express setup that serves JSON and renders client-side in JavaScript to an htmx version where the server returns HTML fragments instead. I compare the two implementations and discuss when htmx makes sense, particularly for server-side developers who want to avoid writing frontend JavaScript...
This is a write-up of a small weekend project of mine: a Node.js/Express server that serves markdown files from a directory as HTML, using middleware to intercept requests for .md files and convert them with the Showdown library. I added a simple string-replacement template so the output is well-formed HTML with a proper page title. The code is on GitHub, with hardening and a possible Docker containerization left as future work...
In this beginner-level walkthrough, I move a static temperature text file from NGINX to a Node.js server. I introduce NGINX and reverse proxying, explain what Node and Express are, and show a short Express setup that serves the file on localhost port 3000, with deploying it left for later...
I reflect on my frustration with JavaScript’s dynamic typing, which I see as a source of avoidable errors, and consider defensive type checking and TypeScript as responses. I also weigh Kyle Simpson’s argument from a JavaScript Jabber interview that, since JavaScript was designed to be dynamically typed, it’s better to embrace that than overlay a type system...
JavaScript is much more consistent across browsers now that Internet Explorer is largely unsupported, but tools for dealing with older browsers still exist. In the post, I cover approaches like libraries, polyfills, and transpilation with Babel, showing examples of arrow functions and backtick templates converted into IE 6-compatible code using Babel’s interactive web tool...
I give a tutorial-style explanation of functions in JavaScript, covering scope and pass-by-value arguments, nested functions, and my preference for passing values in explicitly rather than reaching for outer-scope variables. I then cover functions as first-class citizens, including anonymous and arrow function syntax, passing and returning functions, and using map to apply a function to array elements...
As an iOS developer a week into learning JavaScript, I reflect on what I miss from Swift, including the determinism of compiled code, a complete IDE for debugging, and the ability to fully remove deprecated language features. I also cover what JavaScript has in its favour, such as its low barrier to entry and lack of a required build step...
A follow-up on a todo app I built alongside the Complete Web Developer course, in which I replaced right-click deletion and click-to-cross-out behavior with explicit check and delete buttons on each list item, motivated by discoverability and accessibility concerns. My implementation notes cover attaching handlers via onclick versus addEventListener, the fragility of indexing into childNodes, and innerText versus createTextNode for inserting content. I’ve included links to the source code and a live demo...
A short musing from a developer more used to type-safe languages: I find a JavaScript example uncomfortable and speculate that JavaScript objects may turn out to be just arrays. If so, accessing properties from inside functions would require something like self[2] notation...
I share a quick tip on running JavaScript in VS Code: install Node.js, and the editor will offer it as the runtime the first time you execute a JS file. I also note that the Live Server dev server is accessible to other devices on my network via my machine’s IP address, which is handy for previewing layouts on phones...