Latest Posts

I write about front-end web development. I'm inspired by Nathan Barry's motto, teach everything you know. I also take a lot of inspiration from my friend and mentor, Chris Ferdinandi.

How the Array.prototype.slice.call() trick works

Nowadays, we can convert a NodeList into an array by using the modern Array.from() method. But this requires a polyfill for IE, so I still use the older Array.prototype.slice.call() method sometimes. It’s a lot harder to read, though, so let’s dig into how it works!

The simplest way to check the event.target

I’ve written a couple of posts recently about event delegation and guard clauses. There are many ways you can check the event.target when using event delegation: by its ID, by its classes, by its tag name, by its attributes, and more. But the easiest way is to use the matches() method.

Guard clauses in JavaScript

When using event delegation, you need to make sure the element that fired the event is the one you wanted. This commonly involves wrapping your event handler within a conditional statement. Guard clauses are a way to make this process much cleaner.