ECMAScript 2020


JavaScript Version Numbers

The previous versions of ECMAScript were identified by numbers: ES5 and ES6.

Starting in 2016, the versions are named based on the year they were released, such as ES2016, 2018, 2020, and so on.


New Features in ES2020

Warning

These characteristics are quite recent.

Some older web browsers might require a different code known as a Polyfill.


JavaScript BigInt

JavaScript uses BigInt variables to store large integer values that cannot be represented by a regular JavaScript Number.

JavaScript can only handle integers accurately up to approximately 15 digits.

BigInt can be created by adding 'n' to an integer or calling BigInt().

Thetypeof a BigIntin JavaScript is identified as "bigint".


JavaScript String matchAll()

Before ES2020, there wasn't a string function available to find all instances of a specific string within another string.

If you use a regular expression as a parameter, make sure to set the global flag (g). If it's not set, a TypeError will be thrown.

To perform a case-insensitive search, you need to set the insensitive flag (i).

Note

ES2021 brought in a new string method called replaceAll().


The Nullish Coalescing Operator (??)

The ?? operator gives back the initial value if it's not nullish (either null or undefined).

If not, it gives back the second option.


The Optional Chaining Operator (?.)

The Optional Chaining Operator gives backundefined when an object is eitherundefined ornull without causing an error.


The &&= Operator

The Logical AND Assignment Operator is employed when working with two values.

If the initial value istrue, the subsequent value gets assigned.


The ||= Operator

The Logical OR Assignment Operator connects two values.

If the initial value is false


The ??= Operator

TheNullish Coalescing Assignment Operator is employed when working with two values.

If the initial value is undefined or null, the second value takes its place.


JavaScript Promise.allSettled()

The Promise.allSettled() function gives back a Promise after processing a set of promises.