Image of code sample for the article: What are numeric separators?

What are numeric separators?

When working with large numbers it can be hard to read them out, try to read this value for example: …read more

Image of code sample for the article: JavaScript array methods and how to use them

JavaScript array methods and how to use them

Arrays are as central to JavaScript as in many other languages, in this article we will go through the most useful array methods along with creative usage examples. …read more

Image of code sample for the article: How to build a Web Components app with Redux!

How to build a Web Components app with Redux!

The flux pattern has proved useful for more complex applications. The Redux npm package has been used extensively in React applications for years but can also be used in similar ways with LitElement style web components. …read more

Image of code sample for the article: How to format numbers

How to format numbers

The native Intl.NumberFormat API lets you format numbers for specific languages without any external dependencies. …read more

Image of code sample for the article: Format

Format "5 days ago" localized relative date strings in a few lines with native JavaScript

The native Intl.RelativeTimeFormat API can generate nicely formatted relative date/time strings without any external dependencies. …read more

Image of code sample for the article: Escaping your CSS selectors in the easiest way possible

Escaping your CSS selectors in the easiest way possible

When working a lot on dynamic Web Component apps I have often stumbled on cases where the element properties will be defined by the end-users. To prevent errors when selecting these elements they need to be properly escaped to work with any character. …read more

Image of code sample for the article: How to extract pdf data with PDF.js

How to extract pdf data with PDF.js

We live in a data-driven world, consistently transferring data from one location to another. In this brief tutorial, I will show you how to extract pdf content using PDF.js. This npm package will help you roll out custom pdf extraction logic or an interface to explore pdf data. …read more

Image of code sample for the article: Use more ergonomic custom events

Use more ergonomic custom events

While we have CustomEvent for all of our events that need to carry data the need for the detail property nesting can feel a bit cumbersome. …read more

Image of code sample for the article: 10 great JavaScript tricks that will improve your productivity

10 great JavaScript tricks that will improve your productivity

These top tips and tricks will help you dramatically increase your productivity while coding in any JavaScript project. …read more

Image of code sample for the article: Why should I start using Optional Chaining and Nullish Coalescing operators?

Why should I start using Optional Chaining and Nullish Coalescing operators?

Gone are the days where you had to add incremental nullish (undefined or null) checks when fetching values in nested objects. Let's do more with less code. …read more

Image of code sample for the article: Lets code a plain JavaScript notification queue using private fields and methods

Lets code a plain JavaScript notification queue using private fields and methods

Defining easy-to-use APIs can be tricky, a good starting point is to keep a small exposed surface. Now as private fields are becoming available, let try them out. …read more

Image of code sample for the article: ESLint disable single line and code blocks

ESLint disable single line and code blocks

ESLint is a must-have tool for the editor as well as in your CI setup as it greatly improves code quality, however, sometimes you need to disable some rules. …read more

Image of code sample for the article: Keep your HTML output secure and clean from XSS JavaScript injection

Keep your HTML output secure and clean from XSS JavaScript injection

Writing secure web services can be hard, several attack vectors exist, this article explains how XSS or JavaScript injection can be prevented. …read more

Image of code sample for the article: How-to create and use mixins in JavaScript

How-to create and use mixins in JavaScript

Mixins are handy when you want to share a feature across multiple classes without using inheritance as only some of the child classes should have that feature. …read more

Image of code sample for the article: How to use keyword arguments in JavaScript

How to use keyword arguments in JavaScript

Passing an Object named options to a function instead of separate arguments is one of the oldest tricks in the book, by also assigning an empty object by default you also reduce the amount of if statements needed at the top of the function. But a year ago I learned how combining this with object deconstruction made it so much more elegant. …read more

Image of code sample for the article: Why default exports are bad

Why default exports are bad

Import statements come in a lot of different flavors in JavaScript and where there is variation some of the options are often better than others. For import statements, we want to easily understand which parts of a module we are going to use and also easily get an overview of where those parts are being used throughout our projects. …read more

Image of code sample for the article: How to use lookahead and lookbehind RegExp in JavaScript

How to use lookahead and lookbehind RegExp in JavaScript

Sometimes you want to ensure that a RegExp pattern starts immediately after a specific string but you don't want to include those characters in the match. In these cases, a lookbehind expression comes in handy. …read more

Image of code sample for the article: Rounding a number to a specific precision in JavaScript

Rounding a number to a specific precision in JavaScript

This is a tiny and handy function to round a number to a specific precision: …read more

Image of code sample for the article: Scaling values between two ranges

Scaling values between two ranges

In some cases, you have one type of value with a specific range and you want to scale them proportionally into a new range. …read more

Image of code sample for the article: How to deprecate features in your API before making breaking changes

How to deprecate features in your API before making breaking changes

When creating APIs that external parties depend on you will soon realize the need to be careful about making breaking changes to that API as even a single renamed property/function might cause existing code using your API to fail. …read more

Image of code sample for the article: Why you should always use undefined, and never null

Why you should always use undefined, and never null

To write simple code you need to keep complexity and variation down. I find that where JavaScript offers alternatives, stick to one of them. …read more