DEV Community

Discussion on: What's new in ES2022? πŸ€”

Collapse
 
juvpengele profile image
Juvenal PENGELE • Edited

I may be wrong but I do not think this is correct "For static data we have Static fields and Static Blocks that are executed every time a new instance is created.".

Static blocks are evaluated once during Class definition not every time a new instance is created.
When a new instance is created, it is the code in the construction that is executed.

Collapse
 
jasmin profile image
Jasmin Virdi • Edited

Yes you are right, static blocks are executed when a class is created not in case of instance. Updated the statement.

ThanksπŸ‘