Event delegation is a useful pattern for managing descendant interactions and Element.closest helps with simple and robust code
Tagged "JavaScript"
Browser native text-to-speech is neat, but it lacks the polish that most users expect
JavaScript's Proxy object can be used to watch an object and respond whenever any of its properties are accessed or reassigned
Using sets to de-dupe arrays of primitive and object-like values
Go is the superior for executables based file size and execution time, but Bun and Deno offer a competitive option for developers familiar with the JavaScript ecosystem
You could use an Object, but Maps are probably best for lookup tables and WeakMaps are useful for memory performance
Nullish values are null and undefined, and it's important to thing of them separately from falsy values
There isn’t an event for class list changes, but you can write a function that listens for class changes on an element with the MutationObserver API
Mathias Bynen has a handy tool for determining what characters are allowed in a JS variable name
JavaScript's parseInt, parseFloat, and Number constructors struggle with comma-separated number strings.
Node.js and JavaScript are a great option for scripting for the language features and the large ecosystem. Oh, and it's pretty fast too!
A drop-in replacement for Math.random that generates cryptographically strong random values
A write-up on the new star feature on seanmcp.com
How to make a custom web component with only a few lines of code
Writing a little helper function to grab the HTML of all children of a shallow wrapper in Enzyme
The missing "hello world" example to get up and running with remark
Although JS treats them like object, finding the methods of a class programmatically is trickier than I thought.
How to use URLSearchParams to parse any search parameters string like window.location.search
Since audio and video are native HTML elements, you can change the playing speed with a quick console script
TypeScript provides valuable features but complicate the development process. What are some alternatives that provide the features without the headache?
A sample POST with fetch for those of us who can never remember how.
Sidestep slicing and splicing and use Array's filter method for a no-hassle solution.
This is a WIP that I probably will never finish.
By calling your asynchronous functions before awaiting, you can save valuable time in your JavaScript programs
How to use Deno's standard library to read and parse data from a json file.
How to use Node.js's file system to read and parse data from a json file.
A brief journey into the dangerous world of user agent sniffing
Writing a script to read the package.json for you
Not as easy as we'd like it, but not as hard as it could be
Correcting my mental model
This is a WIP that I probably will never finish.
How to create a custom event listener for class names using the MutationObserver API
Using a console script to alter the content on a webpage
Using JavaScript's Math object to generate random numbers
Demystifying the inline if statement
Browse by tag or all articles.