ES2022 feature: class static initialization blocks

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 initi…


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.

[Read rest of post]


This content originally appeared on 2ality – JavaScript and more and was authored by Dr. Axel Rauschmayer


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » ES2022 feature: class static initialization blocks." Dr. Axel Rauschmayer | Sciencx - Wednesday September 1, 2021, https://www.scien.cx/2021/09/01/es2022-feature-class-static-initialization-blocks/
HARVARD
Dr. Axel Rauschmayer | Sciencx Wednesday September 1, 2021 » ES2022 feature: class static initialization blocks., viewed ,<https://www.scien.cx/2021/09/01/es2022-feature-class-static-initialization-blocks/>
VANCOUVER
Dr. Axel Rauschmayer | Sciencx - » ES2022 feature: class static initialization blocks. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/01/es2022-feature-class-static-initialization-blocks/
CHICAGO
" » ES2022 feature: class static initialization blocks." Dr. Axel Rauschmayer | Sciencx - Accessed . https://www.scien.cx/2021/09/01/es2022-feature-class-static-initialization-blocks/
IEEE
" » ES2022 feature: class static initialization blocks." Dr. Axel Rauschmayer | Sciencx [Online]. Available: https://www.scien.cx/2021/09/01/es2022-feature-class-static-initialization-blocks/. [Accessed: ]
rf:citation
» ES2022 feature: class static initialization blocks | Dr. Axel Rauschmayer | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.