在JS实例里使用 Class 的静态方法

参考:https://stackoverflow.com/questions/43614131/js-call-static-method-from-class

1
2
3
4
5
6
7
8
9
10
11
12
13
class StaticMethodCall {
constructor() {
console.log(StaticMethodCall.staticMethod());
// 'static method has been called.'

console.log(this.constructor.staticMethod());
// 'static method has been called.'
}

static staticMethod() {
return 'static method has been called.';
}
}