JS: New Features 2016 to 2021

By Xah Lee. Date: . Last updated: .

Since 2015, new features are added to JavaScript the language each year.

JS2015

2015 Features

JS2016

JS2017

JS2018

Destructure object rest properties

For example, we have let { c, ...remainProperties } = { a:1, b:2, c:3 };, then c is 3. remainProperties is { a:1, b: 2 } . See: β€’ Destructuring Assignment β€’ Function Argument Destructure

Spread operator for object literal

For example, { ...{ a:1, b:2}, c:3 } becomes { a:1, b:2, c:3 } . See: Spread Operator

Regex Features

promise finally, async iteration

JS2019

JS2020

globalThis
A variable that is alias to the Global Object the Global Object
??
Nullish Coalescing Operator
?.
Optional Chaining Operator
String.prototype.matchAll
String.prototype.matchAll
Property Order Guaranteed
Now object property's order is guaranteed by spec.

bigint

xtodo

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

dynamic import

xtodo

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

Import/Export

import.meta

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

import() syntax

xtodo

Promise.allSettled

xtodo

Promise Tutorial

JS2021

Number Separator
Numbers can have lowline _ between digits. For example, you can write 1_000.
Logical AND assignment operator x &&= y
Assigns y to x if Boolean(x) eval to true. see JS: Operators
Logical OR assignment operator x ||= y
Assigns y to x if Boolean(x) eval to false.
Logical Nullish assignment operator x ??= y
Assigns y to x if x is null or undefined
BUY Ξ£JS JavaScript in Depth