JS: ECMAScript 2020

By Xah Lee. Date: . Last updated: .

globalThis

a variable for the global object

Nullish Coalescing Operator

Optional Chaining Operator

String.prototype.matchAll

easier way to get all matches and all captures.

before, you have to use String.prototype.match with global flag on. if you want all captures of all occurrences, you have to do a loop and rely on advancing RegExp.prototype.lastIndex and sticky flag “y”. (RegExp.prototype.sticky)

Order of Properties

big int

A new number primitive for working with arbitrary precision integers.

const x = 10n;
console.log( typeof x === "bigint" ); // true

also new are typed array of big int:

Dynamic import, the import() syntax

new syntax: import *

import * as xyz from "./xyz.js";

new syntax: export *

xtodo

Dedicated export * as ns from 'module' syntax for use within modules.

import.meta

xtodo

import.meta, a host- populated object available in Modules that may contain contextual information about the Module.

export {abc} from "./xyz.js";
export * from "./xyz.js";

Promise.allSettled

xtodo

A new Promise combinator that does not short-circuit.

Order of for-in loop

Increased standardization of for-in enumeration order.