First, before this question will be downvoited, as you know in ES6 classes keyword static
don't works for class properties. However, we can define it via get methods, as in the example below.
I learned that we can to call the static property inside the class by calling booth class name and this
:
class Animation{
static get SLOW (){ return 900; } // milliseconds
static get FAST (){ return 300; } // milliseconds
static getSlowSpeedValue(){
console.log(this.SLOW); // works
//console.log(Animation.SLOW); // works too
}
}
Animation.getSlowSpeedValue();
Which method is technically right, which is the better practice?
By the way I also learned that we call any static methods inside the class by booth above ways:
class SomeClass{
static method1(){
SomeClass.method2(); // works
//this.method2(); // works too
}
static method2(){
console.log('OK');
}
}
SomeClass.method1();