I am trying to create a new class Dog that inherits via prototypical inheritance from the Animal class:
function Animal() {
this.name = "animal";
this.writeName = function() {
document.write(this.name);
}
}
function Dog() {
this.name = "dog";
this.prototype = new Animal();
}
new Dog().writeName()
However, I get a Javascript error: Uncaught TypeError: Object #<Dog> has no method 'say'.
Why? Shouldn't the Dog object retain an Animal object as a prototype?