ES2021 improves support for promises
The twelfth edition of ECMAScript, ES2021, has been approved with improved support for promises and new logical assignment operators.
Improvements to support for pledges come in the form of promise.everything. ES2020 introduced promise.allSettled it provided a way to keep multiple promises in parallel until they were all settled, either kept or rejected. promise.everything is a variation of this which takes an array of promises and returns the first promise to be successfully fulfilled. If all the promises reject, he rejects too.
Logical assignment operators have been extended with the ability to combine logical operations such as ??, &&, or || with the assignment operator = you can therefore use expressions such as:
x ??= 3
assign 3 at X when X is no or undefined.
Numeric separators are another addition, providing a way to make numeric literals more readable by creating a visual separation between groups of digits. The layout ends up resembling that of numbers when included in a written document:
1_000_000_000 // Ah, so a billion
101_475_938.38 // And this is hundreds of millions
let fee = 123_00; // $123 (12300 cents, apparently)
Low Ref is an addition that provides two major new features, according to the original proposal. Addition can be used to create weak references to objects with the Low Ref class, and also to run user-defined finalizers after the objects have been fetched so that the objects in LowReThe f variables can be safely deleted to free up space.
The latest addition is String.replaceAll. As the name suggests, this adds a way to replace all occurrences of a given string.
Any minor but reasonable improvements – let’s hope there won’t be more revolutions.
ESLint adds ES2020 support
ECMAScript 2018 is full functionality
ECMAScript 2016 approved
or send your comment to: [email protected]