Call static methods from regular ES6 class methods

What’s the standard way to call static methods? I can think of using constructor or using the name of the class itself, I don’t like the latter since it doesn’t feel necessary. Is the former the recommended way, or is there something else?

Here’s a (contrived) example:

class SomeObject {
  constructor(n){
    this.n = n;
  }

  static print(n){
    console.log(n);
  }

  printN(){
    this.constructor.print(this.n);
  }
}

3 Answers
3

Leave a Comment