JavaScript evolves quickly. In 2021, several proposals have moved to Stage 4 of the TC39 process and will be included in ES2022. They add the following features to JavaScript:
Classes and Instances
- Private instance fields, methods, and accessors
- Existence checks for private fields
- Public static class fields
- Private static class fields and methods
- Static class initialization blocks
Module Loading
- Top-Level
await
Built-in Objects
- Error:
.cause
- Array, String, and TypedArray:
.at()
- Object:
.hasOwn()
- RegExp: match
.indices
('d
' flag)
This blog post describes each feature, shows an example of how it can be used, and looks at current browser and Node.js support (as of December 2021). Let's get started: