Home & blog

Using TreeWalker to query non-element nodes

25 Feb 2021

TreeWalkers are a means of traversing a DOM subtree - but one advantage they have over other means is they can be used to select non-element nodes such as comments and text nodes.

JavaScript maps and sets part 2: Weak maps

1 Jan 2021 weak-maps maps javascript

In part two of this in-depth guide to JavaScript maps and sets we'll be looking at the weird, exotic world of weak maps. These are like maps, except the keys are always objects and the entries are "weakly held". We'll explore just what this means.

JavaScript maps and sets part 1: Maps

15 Dec 2020 maps javascript

In this guide we'll be looking at JavaScript maps and sets. First up, maps, which are a sort of super object. They work like objects, but with some key differences and improvements - most notably, they have a reliable order and can accesspt any data type as keys!

Simulting jQuery's on() method

8 Nov 2020

Following up on my recent guide to JavaScript event delegation, I thought it would be interesting to simulate jQuery's on() method, which makes event delegation a breeze by hiding its workings, in native JS.

Introducing Promice.any()

2 Aug 2020 promises javascript

Meet Promise.any(), which is supported by the just-released Firefox 79. It's like Promise.race(), except it listens only for the first promise to be fulfilled, not merely resolved either way.

Resolving ES6 promises from outside

16 Feb 2020 async es6 promises javascript

When the JavaScript Promises specification was released, one of the first questions that got asked (and is still asked) was: but how do I resolve them from outside, a la jQuery deferred objects? That's not how they're intended to work, but it is possible.

How relevant is jQuery in 2020?

8 Jan 2020 jquery javascript

jQuery took the world by storm. It filled in the gaps of JavaScript's then rather sparse API, and made coding MUCH simpler. But the JavaScript API has moved on, and reactive frameworks are the naem of the game. How relevant still is jQuery?

JavaScript Promises part 1: Meet promises

31 Jul 2019 promises javascript

Promises a great way to write shallow, readable code that looks synchronous but actually hides away asynchronous operations. In this first of three articles I'll be showing you how they work, and what problem they solve.

JavaScript generators part 1: Generator basics

25 Feb 2019 generators javascript

Welcome to JavaScript generators! In this article, the first in a three-part guide, I'm going to be introducing the basics of genereator functions, what they're about, how you can use them and give a hint to their deeper capabilities that we'll meet later in the series.