This page covers all standardized features of the next version of ECMAScript (a.k.a ES)
ES2022
- Private Fields – learn how to define private fields in a class.
- Private Methods – show you how to define private methods in a class.
- Top-level await – explain top-level await module and its use cases.
- Array.prototype.at() method – guide you on how to use the Array.prototype.at() method to access array elements.
ES2021
- String.prototype.replaceAll() – replace all occurrences of a substring that matches a pattern with a new one.
- Logical Assignment Operators – introduce to you the logical assignment operators, including
||=,&&=, and??= - Numeric Separator– show you how to make the numbers more readable by using underscores as numeric separators.
- Promise.any() – learn how to use the JavaScript
Promise.any()method to return the firstPromisethat fulfills.
ES2020
- Nullish coalescing operator (
??) – accept two operands and return the right operand if the left one isnullorundefined. - Optional chaining operator (
?.) – simplify the way to access a property located deep within a chain of connected objects without having to check if each reference in the chain isnullorundefined. - Promise.allSettled() – accept a list of promises and returns a new promise that resolves to an array of values, which were settled (either resolved or rejected) by the input promises.
- Dynamic import – show you how to import a module dynamically via the function-like object
import(). - BigInt – introduce you to a new primitive type that can represent whole numbers bigger than 253 – 1, which is the largest number Javascript can reliably represent with the
Numbertype. - globalThis – provide a standard way to access the global object across environments.
ES2019
- Array.prototype.flat() – flatten an array recursively up to a specified depth.
- Array.prototype.flatMap() – execute a mapping function on every element and flatten the result. It is the combination of the
map()followed by theflat()method. - Object.fromEntries() – convert a list of key-value pairs to an Object.
- Optional catch binding – omit the catch binding when the binding would not be used.
- String.prototype.trimStart() – remove the leading whitespace characters of a string.
- String.prototype.trimEnd() – remove the ending whitespace characters of a string.
ES2018
- Object spread operator – use the spread operator (
...) for objects. - Promise.prototype.finally() – execute a piece of code when the promise is settled, regardless of its outcome.
- Asynchronous iterators – learn how to use async iterators to access asynchronous data sources sequentially.
- Async generators – show you how to create an async generator.
ES2017
- Padding a string – show you how to use a pair of methods:
padStart()andpadEnd()that allow you to pad a string with another string to a certain length. - Object.values() – return own enumerable property’s values of an object as an array.
- Object.entries() – return own enumerable string-keyed property
[key, value]pairs of an object. - JavaScript async / await – write asynchronous code in a clearer syntax.
ES2016
- Exponentiation Operator – introduce you to the exponentiation operator (**) that allows you to calculate a base to the exponent power, which is similar to
Math.pow()method. - Array includes() – allow you to check if an element is in an array.
ES versions
The following table describes the editions and official names of ECMAScript:
| Edition | Official name | Date published |
|---|---|---|
| ES12 | ES2021 | June 2020 |
| ES11 | ES2020 | June 2020 |
| ES10 | ES2019 | Summer 2019 |
| ES9 | ES2018 | June 2018 |
| ES8 | ES2017 | June 2017 |
| ES7 | ES2016 | June 2016 |
| ES6 | ES2015 | June 2015 |
| ES5.1 | ES5.1 | June 2011 |
| ES5 | ES5 | December 2009 |
| ES4 | ES4 | Abandoned |
| ES3 | ES3 | December 1999 |
| ES2 | ES2 | June 1998 |
| ES1 | ES1 | June 1997 |