The specification was approved by ECMA International on June 22. ECMAScript 2021 includes the following features:
AggregateError, a new error type to represent multiple errors at once.
Promise.any, a promise combinator that short-circuits when an input value is fulfilled. Promise.any accepts an iterable of promises and returns a single promise that resolves with the value of that promise. If not promises of the iterable fulfill, then the return promise is rejected with AggregateError. This method is the opposite of Promise.all.
WeakRef, for referring to a target object without preserving it from garbage collection. This proposal encompasses major new pieces of functionality: creating weak references to objects with the WeakRefcode class, and running user-defined finalizers after objects are garbage collected, using the FinalizationRegistry class. WeakRef and FinalizationRegistry, another new feature, are considered advanced features, with their correct use requiring careful thought. They are best avoided, if possible.
FinalizationRegistry, to manage registration and de-registration of cleanup operations performed when target objects are garbage collected.
Array.prototype.sort is being made more precise, to reduce the amount of cases resulting in an implementation-defined sort order.
Separators for numeric literals, enabling developers to make numeric literals more readable by creating a visual separation between groups of digits. Large numeric literals are difficult to parse visually, particularly when there are long digit repetitions.
Logical assignment operators, combining logical operators and assignment expressions. Underlying this proposal is the reasoning that there are a dozen mathematical assignment operators but none for often-used logical operators.
ECMAScript 2021 follows ECMAScript 2020, which was formally approved last June. ECMAScript 2020 introduced features ranging from a new import facility for loading modules to a BigInt type to work with arbitrary precision integers.