Why is JavaScript event delegation better than attaching events to each ele
I typically recommend using event delegation for event listeners instead of attaching them to individual elements. Let’s say wanted to listen to clicks on every element with the .sandwich class. You might do this. var sandwiches = document.querySelectorAll('.sandwich'); sandwiches.forEach(function (sandwich) { sandwich.addEventListener('click', function (event) { console.log(sandwich); }, false); }); But with event delegation, you would listen for all clicks on the document and ignore ones on elements without the .
What's the difference between JavaScript event delegation, bubbling, and ca
Yesterday, I wrote about why event delegation is better than attaching events to specific elements. In response, my buddy Andrew Borstein asked: What’s the difference between event delegation/bubbling/capturing? This is a great question that I get fairly often. The terms are often used interchangeably (sometimes by me, oops!), which can cause some confusion. So let’s clear that up today. tl;dr: event delegation is the technique, bubbling is what the event itself does, and capturing is a way of using event delgation on events that don’t bubble.
Patterns and libraries emerged in the JavaScript ecosystem to handle asynchronous programming. Here's a quick guide to our top picks of async patterns.
The Writable Files API: Simplifying local file access | Web | Google De
The File System Access API enables developers to build powerful web apps that interact with files on the user's local device, like IDEs, photo and video editors, text editors, and more. After a user grants a web app access, this API allows them to read or save changes directly to files and folders on the user's device.
Comprehensive Guide to JavaScript Design Patterns | Toptal
Design patterns are reusable solutions to commonly occurring problems in software design. Let's take a look at how they work and explore some popular JavaScript design patterns.
Now You See Me: How To Defer, Lazy-Load And Act With IntersectionObserver —
Intersection information is needed for many reasons, such as lazy loading of images. But there’s so much more. It’s time to get a better understanding and different perspectives on the Intersection Observer API. Ready?
A Gentle Introduction to Functional JavaScript: Part 1
What is all the hype about Functional JavaScript? And why is it called functional? It’s not as though anyone sets out to write dysfunctional Javascript. What is it good for? Why would you bother?
A Gentle Introduction to Functional JavaScript: Part 2
In the previous article, we saw how functions can be used to make certain code abstractions easier. In this article we apply these techniques to arrays and lists.
A Gentle Introduction to Functional JavaScript: Part 3
In the last article, we saw how functional programming can be used with arrays. In this article we examine higher-order functions—functions for making functions.
A Gentle Introduction to Functional JavaScript: Part 4
In the last article of our four-part introduction to functional programming in JavaScript, we looked at higher-order functions. In this article we discuss how to use these new tools with style.
A JavaScript Promise represents the result of an operation that hasn't been completed yet, but will at some undetermined point in the future. An example of such an operation is a network request. When we fetch data from some source, for example an API, there is no way for us