title: Javascript Inheritance
body: <p>How does this syntax <code>Penguin.prototype = new Animal();</code> inherit properties from constructor <code>Animal</code>. It also uses the "new" keyword, why does it use that? as far as I know, it is used to create objects.</p>
  
  <p><strong>Things that I know</strong> -There is actually no "class" in JavaScript. Every constructor/class or object has a prototype. We use "prototype" keyword to add properties or methods to it. We also use it to inherit properties from constructors, like in the above code. We can add methods or properties to object using dot operator, but we can't do that with constructors. </p>
  
  <pre><code>function Animal(name, numLegs) {
      this.name = name;
      this.numLegs = numLegs;
  }
  Animal.prototype.sayName = function() {
      console.log("Hi my name is " + this.name);
  };
  
  
  var Penguin = function(name) {
      this.name = name;
      this.numLegs = 2;
  }    
  
  
  Penguin.prototype = new Animal("lavios",89);
  </code></pre>