ECMAScript 2022 has the following new features:
- Top-level await, allowing the
awaitkeyword to be used 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.
#x in obj#x in objsyntax, to test for the presence of private fields on objects.
- Regular expression match indices via the
/d/dflag, which offers start and end indices for matched substrings.
Errorobjects, to be used to record a causation chain in errors.
atmethod for Strings, Arrays, and TypedArrays, allowing for relative indexing and for use of
Object.hasOwn, an alternative to
Last June’s ECMAScript 2021 standardized capabilities such as
String.prototype.ReplaceAll, for replacing instances of a substring, and the
AggregateError error type.
Copyright © 2022 IDG Communications, Inc.