-
Simplify event delegation with the Element.closest method
Event delegation is a useful pattern for managing descendant interactions and Element.closest helps with simple and robust code
-
Thoughts on Web Speech API
Browser native text-to-speech is neat, but it lacks the polish that most users expect
-
See what object properties are accessed in JavaScript
JavaScript's Proxy object can be used to watch an object and respond whenever any of its properties are accessed or reassigned
-
Remove duplicates from an array in JavaScript
Using sets to de-dupe arrays of primitive and object-like values
-
A quick comparison of JavaScript and Go executables
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
-
Compairing Objects, Maps, and WeakMaps for lookup tables in JavaScript
You could use an Object, but Maps are probably best for lookup tables and WeakMaps are useful for memory performance
-
What is nullish in JavaScript?
Nullish values are null and undefined, and it's important to thing of them separately from falsy values
-
Listen for class change in JavaScript
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
-
Valid JavaScript variable names
Mathias Bynen has a handy tool for determining what characters are allowed in a JS variable name
-
Be careful parsing formatted numbers in JavaScript
JavaScript's parseInt, parseFloat, and Number constructors struggle with comma-separated number strings.
-
Node.js is great for scripting
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!
-
How to replace Math.random with crypto in JavaScript
A drop-in replacement for Math.random that generates cryptographically strong random values
-
Make a web component
How to make a custom web component with only a few lines of code
-
Get innerHTML of Enzyme wrapper
Writing a little helper function to grab the HTML of all children of a shallow wrapper in Enzyme
-
Use remark to covert markdown into HTML
The missing "hello world" example to get up and running with remark
-
Count class methods in JavaScript
Although JS treats them like object, finding the methods of a class programmatically is trickier than I thought.
-
Read URL search parameters with JavaScript
How to use URLSearchParams to parse any search parameters string like window.location.search
-
Increase the playback speed on any audio or video online
Since audio and video are native HTML elements, you can change the playing speed with a quick console script
-
TypeScript without TypeScript
TypeScript provides valuable features but complicate the development process. What are some alternatives that provide the features without the headache?
-
Make a POST request with fetch
A sample POST with fetch for those of us who can never remember how.
-
Remove an item at a given index in JavaScript
Sidestep slicing and splicing and use Array's filter method for a no-hassle solution.
-
Await multiple promises in JavaScript
By calling your asynchronous functions before awaiting, you can save valuable time in your JavaScript programs
-
Read a json file in Deno
How to use Deno's standard library to read and parse data from a json file.
-
Read a json file in Node.js
How to use Node.js's file system to read and parse data from a json file.
-
How to get the browser and version in JavaScript
A brief journey into the dangerous world of user agent sniffing
-
How to check npm scripts in current directory
Writing a script to read the package.json for you
-
How to remove duplicates from an object array?
Not as easy as we'd like it, but not as hard as it could be
-
What default parameters do (and don't do)
Correcting my mental model
-
Add event listener for class change
How to create a custom event listener for class names using the MutationObserver API
-
Filter out premium Medium articles
Using a console script to alter the content on a webpage
-
JS Basics: Generate a random number
Using JavaScript's Math object to generate random numbers
-
JS Basics: Ternary Operator
Demystifying the inline if statement