Skip to content

Instantly share code, notes, and snippets.

@ivankisyov
Created December 24, 2018 12:13
Show Gist options
  • Save ivankisyov/da683d42463c83cc5d9c216cf7248878 to your computer and use it in GitHub Desktop.
Save ivankisyov/da683d42463c83cc5d9c216cf7248878 to your computer and use it in GitHub Desktop.
Static methods in JS "Classes"

Static methods in JS "Classes"

Methods that must be invoked on the class itself, not on its instances

class Human {
  constructor(name) {
    this.name = name;
  }
  
  getName() {
    return this.name;
  }
  
  static isFromEarth() {
    return true;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment