ECMAScript 2022 features eight finished proposals:
- Ergonomic brand checks for private fields, providing brand checks without exceptions.
await, which enables modules to act as big async functions. With top-level
await, ECMAScript modules can await code resources, causing other modules that
importthem to wait before starting to evaluate the body.
RegExpMatch indices, which provide additional information about the start and end indices of captured substrings relative to the start of the input string.
.at()method on all the built-in indexables, adding an
.at()method to all basic indexable classes, including Array, String, and TypedArray. This provides a solution for “negative indexing” of JS arrays, similar to Python.
staticblocks, which provide a mechanism for additional static initialization during class definition evaluation. This is not intended as a replacement for public fields but is intended to augment existing use cases while enabling new use cases not currently handled by that proposal.
Object.prototype.hasOwnProperty(), which provides for an
Object.hasOwn()method to make
- Error cause, for accumulating errors. The proposal calls for adding an options parameter to the
Error()constructor with a
causeproperty, the value of which will be assigned to the error instances as a property. Errors can be chained without unnecessary and overelaborate formalities on wrapping the errors in conditions.
Last June’s ECMAScript 2021 offered capabilities such as
String.prototype.ReplaceAll, for replacing instances of a substring, and the
AggregateErrorcode error type.
Copyright © 2022 IDG Communications, Inc.