structuredClone()
: deeply copying objects in JavaScriptSpreading is a common technique for copying objects in JavaScript:
Spreading has one significant downside – it creates shallow copies: The top levels are copied, but property values are shared.
structuredClone()
is a new function that will soon be supported by most browsers, Node.js and Deno. It creates deep copies of objects. This blog post explains how it works.
The ecosystem around delivering ECMAScript modules via packages is slowly maturing. This blog post explains how the various pieces fit together:
node:
protocol importsNode.js now supports a node:
protocol for built-in modules.
The ECMAScript proposal “Class static initialization blocks” by Ron Buckton is at stage 4 and scheduled to be included in ECMAScript 2022.
For setting up an instance of a class, we have two constructs in JavaScript:
For setting up the static part of a class, we only have static fields. The ECMAScript proposal introduces static initialization blocks for classes, which, roughly, are to static classes what constructors are to instances.
Iteration is a standard that connects operations with data containers: Each operation that follows this standard, can be applied to each data container that implements this standard.
In this blog post:
.map()
, .filter()
, and .forEach()
.A monorepo is a single repository that is used to manage multiple projects. In this blog post, we’ll explore how to set up a simple monorepo for two npm packages. All we need is already built into npm and TypeScript.
In this blog post, I’ll explain everything you need to know in order to use and produce native ECMAScript modules on Node.js.
The GitHub repository iterable
is an example of a TypeScript ESM package that works on Node.js. It still uses the "typesVersions"
workaround (which isn’t needed in TypeScript 4.7 and later).
Date
, JavaScript’s current date time API is infamously difficult to use. The ECMAScript proposal “Temporal” is a new and better date time API and currently at stage 3. It was created by Philipp Dunkel, Maggie Johnson-Pint, Matt Johnson-Pint, Brian Terlson, Shane Carr, Ujjwal Sharma, Philip Chimento, Jason Williams, and Justin Grant.
This blog post has two goals:
However, it is not an exhaustive documentation: For many details, you will have to consult the (excellent) documentation for Temporal.
Warning: These are my first explorations of this API – feedback welcome!
In this blog post, we examine the ECMAScript proposal “Ergonomic brand checks for private fields” (by Jordan Harband). It proposes a compact way for checking if an object has a given private field.
Object.prototype.hasOwnProperty()
In this blog post, we examine the ECMAScript proposal “Accessible Object.prototype.hasOwnProperty()
” (by Jamie Kyle and Tierney Cyren). It proposes a new, simpler way of checking if an object has an own (non-inherited) property.