2019-10

Type coercion in JavaScript

[2019-10-31] dev, javascript, es spec

In this blog post, we examine the role of type coercion in JavaScript. We will go relatively deeply into this subject and, e.g., look into how the ECMAScript specification handles coercion.

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.