Following this solution I have the following class:
com.temp.System = class {
static initialize() {
this.foo = 9;
console.log("foo 1 is: " + this.foo);
}
static testMe() {
console.log("foo 2 is: " + this.foo);
}
}
This is how I use it:
{
const System = com.temp.System;
System.initialize();
System.testMe();
}
And this is output:
foo 1 is: 9
foo 2 is: 9
And I have two questions:
- What is the best way to create static fileds in such solution?
- Why
this.foo
works although I don't create instances of this class?