In ES6, I can create static methods like below. But I need to define a static constructor but no success. I need something that runs only once when the class is loaded. I Is
I need something that runs only once when the class is loaded.
You shouldn't be using classes if you just use them as a bag of methods. Use an object instead. However, it's still possible to run such code. Just put it before or after the class definition.
console.log('before class is created')
class Foo {}
console.log('after class was created');