ECMAScript 2022 blesses class elements, high-level expectation

ECMAScript 2022, the next update to the official standard behind JavaScript, has been officially approved, with new features ranging from class elements to next-level waitability.

The ECMAScript 2022 specification was approved by ECMA International on June 22. But the features are already available in most browsers, said Robert Palmer, co-chair of the TC39 committee that manages the standard, in March. Feature availability in JavaScript engines is more relevant to developers than appearance in the actual specification, Palmer said.

ECMAScript 2022 has the following new features:

  • High-level expectation, allowing the await keyword to use at the top level of modules.
  • New class elements, including public and private instance fields, public and private static fields, and private instance methods and accessors.
  • Static blocks within classes, to perform per-class evaluation initialization.
  • The #x in obj#x in obj syntax, to test the presence of private fields on objects.
  • Regular expression matching index via the /d/d flag, which provides start and end indices for matching substrings.
  • The cause property on Error objects, to be used to record a causal chain in errors.
  • The at method for Strings, Arrays and TypedArrays, allowing relative indexing and the use of Object.hasOwnan alternative to Object.prototype.hasOwnProperty.

ECMAScript 2021 standardized capabilities from last June such as String.prototype.ReplaceAllto replace instances of a substring, and the AggregateError type of error.

Copyright © 2022 IDG Communications, Inc.

Comments are closed.