This content originally appeared on 2ality – JavaScript and more and was authored by Dr. Axel Rauschmayer
The ECMAScript proposal “Class static initialization blocks” by Ron Buckton is at stage 4 and scheduled to be included in ECMAScript 2022.
For setting up an instance of a class, we have two constructs in JavaScript:
- Field: Create (and optionally initialize) instance properties.
- Constructor: A block of code that is executed before setup is finished.
For setting up the static part of a class, we only have static fields. The ECMAScript proposal introduces static initialization blocks for classes, which, roughly, are to static classes what constructors are to instances.
This content originally appeared on 2ality – JavaScript and more and was authored by Dr. Axel Rauschmayer
Dr. Axel Rauschmayer | Sciencx (2021-09-01T00:00:00+00:00) ES2022 feature: class static initialization blocks. Retrieved from https://www.scien.cx/2021/09/01/es2022-feature-class-static-initialization-blocks/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.