ECMAScript 2021


JavaScript Version Numbers

Earlier versions of ECMAScript were identified by numbers, such as ES5 and ES6.

Starting in 2016, the versions are labeled according to the year they were released: ES2016, 2018, 2020, and so on.

New Features in ES2021

Warning

These characteristics are quite recent.

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


JavaScript Promise.any()


JavaScript String ReplaceAll()

ES2021 added a new string function called replaceAll().

The replaceAll() method lets you use a regular expression instead of a string for replacement.

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

Note

ES2020 brought in a new string method called matchAll().


JavaScript Numeric Separator (_)

ES2021 added a numeric separator (_) to enhance the readability of numbers.

The number separator is just for looks.

You can put the numeric separator anywhere in a number.

Note

Numeric separators should not be placed at the start or end of a number.

In JavaScript, only variables are allowed to begin with an underscore (_).