ECMAScript 2021 spec for JavaScript crosses the finish line

ECMAScript 2021, the latest version of the official specification underlying JavaScript, has been formally approved, adding capabilities for strings and promises.[ Keep up with the latest developments in JavaScript and software development. Subscribe to the InfoWorld First Look newsletter ] The specification was approved by ECMA International on June 22. ECMAScript 2021 includes the following features:String.prototype.ReplaceAll, providing developers with a way to replace all instances of a substring in a string without the use of a global regexp. There is evidence that developers are trying to accomplish this in JavaScript, with a global regexp currently the most-common way of achieving this. String.prototype.replace, meanwhile, affects only the first occurrence when used with a string argument. The proposed solution would add a replaceAll method to the String prototype, providing developers with a straightforward solution. 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.To read this article in full, please click here

Nov 30, -0001 - 00:00
 0
ECMAScript 2021 spec for JavaScript crosses the finish line
Techatty All-in-1 Publishing
Techatty All-in-1 Publishing

ECMAScript 2021, the latest version of the official specification underlying JavaScript, has been formally approved, adding capabilities for strings and promises.

The specification was approved by ECMA International on June 22. ECMAScript 2021 includes the following features:

  • String.prototype.ReplaceAll, providing developers with a way to replace all instances of a substring in a string without the use of a global regexp. There is evidence that developers are trying to accomplish this in JavaScript, with a global regexp currently the most-common way of achieving this. String.prototype.replace, meanwhile, affects only the first occurrence when used with a string argument. The proposed solution would add a replaceAll method to the String prototype, providing developers with a straightforward solution.
  • 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.

To read this article in full, please click here

Talk to Techatty
Talk to Techatty
Techatty Connecting the world of tech differently! Read. Write. Learn. Thrive. Make an informed decision without distractions. We are building tech media and publication networks to connect YOU and everyone to reliable information, opportunities, and resources to achieve greater success.
Vote HARRIS for PRESIDENT.
Vote HARRIS for PRESIDENT.