Since when we declare a function we get its prototype\'s constructor property point to the function itself, is it a bad practice to overwrite function\'s prototype like so:<
This form:
LolCat.prototype = {
hello: function () {
alert('meow!');
}
};
Destroys any existing methods and public properties. In the example, as given, it doesn't matter as the newly created LolCat doesn't have any properties or methods. However, one should be mindful of this in more complicated code.
This form:
LolCat.prototype.hello = function () { ... }
Adds a new method to an existing object and keeps the existing intact.