Use more ergonomic custom events
2020-09-21
While we have CustomEvent for all of our events that needs to carry data the need for the detail property nesting can feel a bit cumbersome. …read more
10 great JavaScript tricks that will improve your productivity
2020-09-21
These top tips and tricks will help you dramatically increase your productivity while coding in any JavaScript project. …read more
Why should I start using Optional Chaining and Nullish Coalescing operators?
2020-09-20
Gone are the days there you had to add incremental nullish (undefined or null) checks when fetching values in nested objects. Lets do more with less code. …read more
Lets code a plain JavaScript notification queue using private fields and methods
2020-09-18
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
ESLint disable single line and code blocks
2020-09-16
ESLint is a must have tool 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
Keep your HTML output secure and clean from XSS JavaScript injection
2020-09-15
Writing secure web services can be hard, several attack vectors exists, this article explains how XSS or JavaScript injection can be prevented. …read more
How-to create and use mixins in JavaScript
2020-09-15
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
How to use keyword arguments in JavaScript
2020-09-15
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 in 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
Why default exports are bad
2020-09-15
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
How to use lookahead and lookbehind RegExp in javascript
2020-09-15
Sometimes you want to ensure that a RegExp pattern starts immediately after a specific string but you don't want to include those characers in the match. In these cases a lookbehind expression comes in handy. …read more
Rounding a number to a specific precision in JavaScript
2020-09-13
The Math.round function will always round to a whole number and sometimes you want to round a number to a specific precision. …read more
Scaling values between two ranges
2020-09-13
In some cases you have one type of values with a specific range and you want to scale them proportionally into a new range. …read more
How to deprecate features in your API before making breaking changes
2020-09-13
When creating APIs that external parties depends on you will soon realize the need being 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
Why you should always use undefined, and never null
2020-09-12
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