So I'm just beginning with JS, and I couldn't seem to find an answer to this simple and possibly stupid question. Why should I do this:
function Cat() {}
Cat.prototype.meow = function() {
...
}
instead of this:
function cat_meow() {
...
}
function Cat() {
this.meow = cat_meow;
}
Because in the second snippet I still only define the function once, so what's the problem with using that instead of prototype
?
EDIT: This question is not quite the same as the one linked as a duplicate. Please reread my question.