18. Dry Penguins Strange Output - {}


18. DRY Penguins

For some reason, the console outputs {} when I run my code below. It allows me to continue to the next lesson but I want to understand where the {} is coming from...

I tried refreshing the page and re-submitting the code

// the original Animal class and sayName method
function Animal(name, numLegs) {
    this.name = name;
    this.numLegs = numLegs;
Animal.prototype.sayName = function() {
    console.log("Hi my name is " + this.name);

// define a Penguin class
function Penguin(name) {
    this.name = name;
    this.numLegs = 2;

// set its prototype to be a new instance of Animal
Penguin.prototype = new Animal();


Creates new, empty Animal.



I have a question.

Why the constructor of Penguin need to have a para called name?
Penguin inherit Animal which have had the property called name.
Can't Penguin reuse it?

Thanks cade