js call static method from class

后端 未结 5 2186
南旧
南旧 2020-12-03 16:49

I have a class with a static method:

class User {
  constructor() {
    User.staticMethod();
  }

  static staticMethod() {}
}

Is there som

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 17:29

    static things bind to class rather than instance. So you must at least specify the class name.

    If you don't want to bind to them to a class make them global.

提交回复
热议问题