2021-06

Temporal: getting started with JavaScript’s new date time API

[2021-06-28] dev, javascript, es proposal

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:

  • Giving you a feeling for how Temporal works
  • Helping you get started with it

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!

ECMAScript proposal: Ergonomic brand checks for private fields

[2021-06-19] dev, javascript, es proposal

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.

ECMAScript proposal: Accessible Object.prototype.hasOwnProperty()

[2021-06-17] dev, javascript, es proposal

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.

ECMAScript proposal: JSON modules

[2021-06-16] dev, javascript, es proposal

In this blog post, we examine the ECMAScript proposal “JSON modules” (by Sven Sauleau, Daniel Ehrenberg, Myles Borins, and Dan Clark). It lets us import JSON data as if it were an ECMAScript module.

ECMAScript proposal: Error cause (chaining errors)

[2021-06-15] dev, javascript, es proposal

In this blog post, we examine the ECMAScript proposal “Error cause” (by Chengzhong Wu and Hemanth HM). It describes a feature where instances of Error can optionally specify that they were caused by another error.

2021-01

undefined vs. null revisited

[2021-01-27] dev, javascript, jshistory

Many programming languages have one “non-value” called null. It indicates that a variable does not currently point to an object – for example, when it hasn’t been initialized yet.

In contrast, JavaScript has two such non-values: undefined and null. In this blog post, we examine how they differ and how to best use or avoid them.

ECMAScript proposal: Import assertions

[2021-01-11] dev, javascript, es proposal

The ECMAScript proposal “Import assertions” (by Myles Borins, Sven Sauleau, Dan Clark, and Daniel Ehrenberg) introduces syntax for associating metadata with import statements. In this blog post, we examine what that looks like and why it’s useful.

Looping over Arrays: for vs. for-in vs. .forEach() vs. for-of

[2021-01-07] dev, javascript

This blog post compares four ways of looping over Arrays:

  • The for loop:

    for (let index=0; index < someArray.length; index++) {
      const elem = someArray[index];
      // ···
    }
    
  • The for-in loop:

    for (const key in someArray) {
      console.log(key);
    }
    
  • The Array method .forEach():

    someArray.forEach((elem, index) => {
      console.log(elem, index);
    });
    
  • The for-of loop:

    for (const elem of someArray) {
      console.log(elem);
    }
    

for-of is often the best choice. We’ll see why.

2020-10

Running Node.js on iOS and iPadOS via iSH

[2020-10-24] dev, javascript, nodejs, ios, ipados

The iOS/iPadOS app iSH is available on the app store and runs Linux via x86 emulation. And you can install Node.js on it!

Writing JavaScript tools in other languages – a new trend?

[2020-10-07] dev, javascript, jstools

Recently, we have seen an uptick of JavaScript tools being written in languages other than JavaScript. This blog post lists a few examples and explains the appeal of not using JavaScript.