I'd like to know if Javascript's class
syntax support static, or class variables in the following way
class MyClass {
var myVar = 0;
//I have also tried these combinations of keywords
static var myVar = 0;
static myVar = 0;
this.myVar = 0;
this.var myVar = 0;
}
MyClass.myVar //0
I see that this is possible using the this
keyword when defining a class with the function
keyword, but I don't see if it's possible using class
. I would hope it is, considering the class
syntax supports static functions. I have tried the following.
I do not wish to use the constructor
method, because then the variable would be an instance variable, and that's not what I'm asking for.