DEV Community

Discussion on: Class Static Initialization Blocks in JavaScript

 
peerreynders profile image
peerreynders • Edited

Then this is just one more utterly pointless feature added to the language for bloat and giggles.

Motivations

For example, if you need to evaluate statements during initialization (such as try..catch), or set two fields from a single value, you have to perform that logic outside of the class definition.

Personally in JavaScript I've always viewed class itself as bloat (composition over inheritance and all that) - but with the introduction of custom elements its existence has been pretty much cemented into JS for all eternity.

When I do feel compelled to use classes they're usually just wrappers using core module functionality expressed in terms of plain objects and functions.