调用静态方法的标准方法是什么?我可以考虑使用constructor或使用类本身的名称,我不喜欢后者,因为它没有必要.前者是推荐的方式,还是还有其他的东西?
这是一个(人为的)例子:
class SomeObject {
constructor(n){
this.n = n;
}
static print(n){
console.log(n);
}
printN(){
this.constructor.print(this.n);
}
}
Run Code Online (Sandbox Code Playgroud)