JavaScript Static Methods
Static methods are methods modified with the static keyword, also called class methods. They belong to the class, but not to objects. Before instantiating an object, they can be called viaClassName.MethodNameCall the static method.
Static methods cannot be called on objects; they can only be called on the class.
Example
class Example {
constructor(name) {
this.name = name;
}
static hello() {
return "Hello!!";
}
}
let noob = new Example("Example");
//You can call the 'hello()' method on the class
document.getElementById("demo").innerHTML = Example.hello();
//You cannot call static methods on an instantiated object
// document.getElementById("demo").innerHTML = noob.hello();
//The above code will throw an error
Try it Yourself »
Calling a static method on an instance object will throw an error:

If you want to use a static method on the object noob, you can pass it as a parameter:
Example
class Example {
constructor(name) {
this.name = name;
}
static hello(x) {
return "Hello " + x.name;
}
}
let noob = new Example("Example");
document.getElementById("demo").innerHTML = Example.hello(noob);
Try it Yourself »