In this answer on a question about inheritance in JavaScript, Oriol adds the line
Cat.prototype.constructor = Cat;
What is this for?
Could you give me an example of one (or some) bad things that could happen if this were omitted and the inheritance was simply:
function Animal(name, sound) {
this.name = name;
this.sound = sound;
}
function Cat(name) {
Animal.call(this, name, 'Meow');
}
Cat.prototype = Object.create(Animal.prototype);