I've seen this asked but I still don't understand the purpose of a static declaration of a method.
class Dog {
constructor(breed) {
this.breed = breed;
}
}
The below is part I don't understand the true difference:
Dog.color = function () {
return "black";
}
vs
Dog.prototype.color = function () {
return "brown";
}
I understand that the protype function allows the method color
to be called on whatever instance I created. Ex: var foo = new Dog()
. foo.color()
;
But what is use case of a static method though if it can't be called on instances of the class?