why do we need static methods in class of javascript.
class Car {
constructor(brand) {
this.carname = brand;
}
static hello(x) {
return "Hello " + x.carname;
}
}
mycar = new Car("Ford");
document.getElementById("demo").innerHTML = Car.hello(mycar);
I know that , Static methods are called directly on the class (Car from the example above) - without creating an instance/object (mycar) of the class. But what's the use of/point of static method in classes JS.