2019-10

Regular expressions in JavaScript: lookaround assertions by example

[2019-10-27] dev, javascript, regexp

These are lookaround assertions in regular expressions in JavaScript:

  • Positive lookahead: (?=«pattern»)
  • Negative lookahead: (?!«pattern»)
  • Positive lookbehind: (?<=«pattern»)
  • Negative lookbehind: (?<!«pattern»)

This blog post shows examples of using them.

Hybrid npm packages (ESM and CommonJS)

[2019-10-22] dev, javascript, jsmodules, nodejs, esm, commonjs

In this blog post, we look at npm packages that contain both ES modules and CommonJS modules.

The problems of shared mutable state and how to avoid them

[2019-10-21] dev, javascript, deepjs

This blog post answers the following questions:

  • What is shared mutable state?
  • Why is it problematic?
  • How can its problems be avoided?

Compiling TypeScript via webpack and babel-loader

[2019-10-12] dev, typescript, webpack, babel

ts-loader has one downside: We can’t pipe the output of another loader into it; it always reads the original file. As a work-around, we can use babel-loader to compile TypeScript. This blog post explains how.

Letting web app users run multi-module JavaScript code

[2019-10-11] dev, javascript

In a web app of mine, I wanted to let end users run multi-module JavaScript that they enter via text fields. It turns out that this simple idea is relatively difficult to implement. In this blog post, I’ll explain how to do it. It is less polished than usual – I mainly wanted to get the knowledge out there.

Evaluating JavaScript code via import()

[2019-10-01] dev, javascript

The import() operator lets us dynamically load ECMAScript modules. But they can also be used to evaluate JavaScript code (as Andrea Giammarchi recently pointed out to me), as an alternative to eval(). This blog post explains how that works.

2019-08

ES2020: Nullish coalescing for JavaScript

[2019-08-19] dev, javascript, es feature, es2020

This blog post describes the ECMAScript feature proposal “Nullish coalescing for JavaScript” by Gabriel Isenberg. It proposes the ?? operator that replaces || when it comes to providing default values.

ES feature: globalThis

[2019-08-07] dev, javascript, es feature, es2020

The ECMAScript proposal “globalThis” by Jordan Harband provides a new standard way of accessing the global object.

Remainder operator vs. modulo operator (with JavaScript code)

[2019-08-05] dev, javascript

You may have read that JavaScript’s % operator is a remainder operator, not a modulo operator. This blog post explains what that means.

JavaScript Promise combinators: .all(), .race(), .allSettled()

[2019-08-04] dev, javascript, es feature, es2020, promises

In this blog post, we take a look at three static methods of Promise:

  • Promise.all() and Promise.race() which JavaScript has had since ECMAScript 6 when Promises were added to the language.
  • Promise.allSettled() which recently advanced to stage 4 and will therefore be part of ECMAScript 2020.