title: How to use parent and child Constructors in Javascript?
body: <p>I am trying to understand why and when we use constructors in Javascript.
  I was wondering when and how we need to use the constructor of a child and when the parents. Based on my tests there is NO difference when I set the child constructor to itself or to the parent.Lets take a look at the below code : </p>
  
  <pre><code>function Mammal(name) {
      this.name = "###"+name;
  }
      Cat.prototype = new Mammal();        // Here's where the inheritance occurs 
      Cat.prototype.constructor = Cat;       // Otherwise instances of Cat would have a    
  
  function Cat(name) {
      this.name = name;
  }
  </code></pre>
  
  <p>Now lets instantiate the Cat and Mamal class and see the name: </p>
  
  <pre><code>var mycat = new Cat('Felix');
  Alert(mycat.name);         //OUTPUT : "Felix"
  </code></pre>
  
  <p>Now i want to set the constructor of Cat class to the Mamal. To do so I remove the below line </p>
  
  <pre><code>//Cat.prototype.constructor = Cat; --&gt;Now the cat Constructor is set to its default(Mamal)
  </code></pre>
  
  <p><strong>Now I expect that when I call mycat.name, it uses the Mamal constructor and alert "###Felix"
  BUT it doesn't. It shows exactly same as the previous result "Felix".</strong></p>
  
  <pre><code>var mycat = new Cat('Felix');
  Alert(mycat.name);         //Again OUTPUT is : "Felix" !! but I expected "###Felix"
  </code></pre>
  
  <p>So, why? And can you give me an example of a correct use of constructors in Javascript and when they are important?</p>