The twelfth edition of ECMAScript, ES2021, has been approved with improved support for promises and new logical assignment operators.
ECMAScript is the language standard on which JavaScript is based, though JavaScript predates it from its original development at NetScape. The standard was originally set out as a formal description of JavaScript to guide the future of the language.
[画像:ecma]The improvements to support for Promises comes in the form of promise.any. ES2020 introduced promise.allSettled that provided a way to run multiple promises in parallel until they were all settled, either as fulfilled or as rejected. promise.any is a variation on this that takes an array of promises and returns the first promise to be fulfilled successfully. If all the promises reject, it too rejects.
Logical assignment operators have been extended with the ability to combine logical operations such as ??, &&, or || with the assignment operator = so you can use expressions such as:
x ??= 3
to assign 3 to x when x is null 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 looking like the way numbers would 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)
WeakRef is an addition that provides two major new pieces of functionality, according to the original proposal. The addition can be used to create weak references to objects with the WeakRef class, and also to run user-defined finalizers after objects have been garbage collected so objects from WeakRef variables can be safely removed to free up space.
The final addition is String.replaceAll. As the name suggests, this adds a way to replace all the occurrences of a given string.
All minor but reasonable improvements - let us hope for no more revolutions.
[画像:ecma]
- Ian Elliot is the author of several JavaScript titles. Just JavaScript: An Idiomatic Approach is intended for programmers who are familiar with another language. It takes a radical look at JavaScript that takes account of the way it is object-based. JavaScript Async covers asynchronous programming in JavaScript, async/await, Promises, Service Workers and so on. His most recent book, JavaScript Bitmap Graphics with Canvas, shows you how to use Canvas to create graphics without resorting to a library of any kind.
More Information
Related Articles
ECMAScript 2018 Is Feature Complete
JavaScript The Language With Two Names
The JavaScript Encyclopedia Work In Progress
JavaScript Added To Oxford English Dictionary
JavaScript 6 EcmaScript 2015 Final Approval
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
What Does JetBrains Survey Tell Us About AI
29/10/2025
The results of the 2025 JetBrains Developer Survey are out and indicate just how deeply AI tools have become embedded into software development. However, while 85% use AI tools for coding and de [ ... ]
W3C Adopts A New Logo
31/10/2025
The World Wide Web Consortium (W3C) is rolling out a new logo following the release of strategic objectives to support W3C's roadmap and the formation in 2023 of W3C as a non-profit, public-interest o [ ... ]
- .NET 10, C# 14 and F# 10 Released Alongside Visual Studio 2026
- Blockly Moving To Raspberry Pi Foundation
- Microsoft Announces GitHub Copilot App For Java And .NET
- Europe Gets Its Own LLM
- Mico - A Personality For Copilot
- TestSprite 2.0 Sees User Growth
- Apple Extends Bug Bounty Program
- Amazing Clocks
- GitHub Copilot CLI And Spaces In Preview
- Google AI Studio Does Angular
- Insectile Garments For Dutch Design Week
- Memgraph Adds AI Graph Toolkit
- Epic Settles With Google - Abandons The Rest Of Us
Comments
or email your comment to: comments@i-programmer.info
<ASIN:1871962579>
<ASIN:1871962560>
<ASIN:1871962625>