The program can still run normally even if I comment the line Dog.prototype.constructor=Dog, why?
<p>The following code is from <strong>JavaScript by Example Second Edition</strong>, it works well.
I can't understand completely the usage <strong>constructor</strong>, after I comment the line Dog.prototype.constructor=Dog and Cat.prototype.constructor=Cat
I find it work wells too and I get the same result, why? Thanks!</p>

<pre><code>&lt;html&gt;
&lt;head&gt;&lt;title&gt;Creating a subclass&lt;/title&gt;
&lt;script type="text/javascript"&gt;
 function Pet(){ // Base Class
 var owner = "Mrs. Jones";
var gender = undefined;
 this.setOwner = function(who) { owner=who;};
this.getOwner = function(){ return owner; }
 this.setGender = function(sex) { gender=sex; }
this.getGender = function(){ return gender; }
}
 function Cat(){} //subclass constructor
 Cat.prototype = new Pet();
Cat.prototype.constructor=Cat;
 Cat.prototype.speak=function speak(){
return("Meow");
};
 function Dog(){};//subclass constructor
 Dog.prototype= new Pet();
Dog.prototype.constructor=Dog;
Dog.prototype.speak = function speak(){
return("Woof");
};
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;&lt;big&gt;
&lt;script&gt;
var cat = new Cat;
var dog = new Dog;
cat.setOwner("John Doe");
cat.setGender("Female");
 dog.setGender("Male");
 document.write("The cat is a "+ cat.getGender()+ " owned by "
+ cat.getOwner() +" and it says " + cat.speak());
document.write("&lt;br&gt;The dog is a "+ dog.getGender() +""+
" owned by " + dog.getOwner() + " and it says "
+ dog.speak());
&lt;/script&gt;
&lt;/big&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
