Besides the Error constructor, JavaScript provides a set of subclasses that we can use to indicate particular types of errors. These subclasses are SyntaxError, TypeError, URIError, RangeError, ReferenceError, and EvalError. ES2021 adds one more subclass to this list: AggregateError. AggregateError is designed to represent multiple errors in a single object. In situations where multiple errors are possible, like a user input form, it makes sense to group errors. That way you can throw a single error that represents all of the errors instead of one for each invalid input.

The JavaScript language was invented to respond to user interactions on web pages. While most interactions are infrequent, some may happen repeatedly in a short period of time. If you code your program to execute a CPU-intensive function with each interaction, you might slow down the browser. You can’t simply remove the function because it’s a critical part of your program, but you also can’t let it undermine the performance of your program. The solution is to implement a debounce function.

A trailing comma, also known as a dangling or terminal comma, is a comma symbol that is typed after the last item of a list of elements. Since the introduction of the JavaScript language, trailing commas have been legal in array literals. Later, object literals joined arrays. And with the introduction of ES2017, also known as ES8, trailing commas became allowed pretty much everywhere. In this guide, we’ll look at trailing commas in detail.

It’s an exciting time to be a JavaScript programmer. Web technologies are moving forward at a faster rate, and browser vendors are no longer shy to implement new and innovative features right away. In this article, we’ll look at six ES2020 and ES2021 features that have recently been implemented by modern browsers and see how they help JavaScript developers write less error-prone and more efficient code.

While the regex syntax might appear daunting at first, once you get the hang of it, you can accomplish tasks that would otherwise require dozens of lines of code. In this article, we’ll look at four new regex features in ECMAScript that help web developers write less error-prone and more efficient code.

Almost all popular programming languages support regular expressions, and there’s a good reason for that: regular expressions provide developers with remarkably powerful tools that enable them to quickly perform tasks that would otherwise require dozens of lines of code. In this article, we will look at six text processing and manipulation tasks that front-end developers often have to deal with and see how regular expressions simplify the process.

The different ways of referencing the global object have made it tough to write a portable JavaScript code that works in multiple environments. Fortunately, there’s a proposal in the works that aims to fix this issue by introducing a standard property called globalThis that will be available in all environments. In this article, we’ll first look at the global object in popular JavaScript environments and then see how globalThis provides a unified mechanism to access it.

In my recent post “How to make HTTP requests like a pro,” I discussed the benefits of using the Axios library. Nevertheless, it’s important to acknowledge that Axios is not always an ideal solution, and there are sometimes better options for making HTTP requests. Without question, some developers prefer Axios over built-in APIs for its ease of use. But many overestimate the need for such a library. The fetch() API is perfectly capable of reproducing the key features of Axios, and it has the added advantage of being readily available in all modern browsers.