Old JS versions are named by numbers: ES5 (2009) and ES6 (2015).
From 2016, versions are named by year: ECMAScript 2016, 2017, 2018, 2019, ...
New Features in ES2021
- Promise any():
const first = await Promise.any([prom1,prom2,prom3]);
- String replaceAll()
- Numeric Separators (_)
These features are relatively new.
Older browsers may need an alternative code (Polyfill)
ES2021 introduced the string method
text = text.replaceAll("cats","dogs");
replaceAll() method allows you to specify a
regular expression instead of a string to be replaced.
If the parameter is a regular expression, the global flag (g) must be set, otherwise a TypeError is thrown.
text = text.replaceAll(/cats/g,"dogs");
ES2020 introduced the string method matchAll().
ES2021 intoduced the numeric separator (_) to make numbers more readable:
The numeric separator is only for visual use.
const num2 = 1000000000;
(num1 === num2);
The numeric separator can be placed anywhere in a number:
The numeric separator is not allowed at the beginning or at the end of a number.
The numeric separator is supported in all modern browsers since January 2020:
|Chrome 75||Edge 79||Firefox 74||Safari 13.1||Opera 67|
|Jun 2019||Jan 2020||Oct 2019||Sep 2019||Jun 2019|