title: Why I can't access a property of parent class from child class instance in JS inheritance?
body: <p>I have two classes. I want to access <code>type</code> property of Parent from instance:</p>
  
  <pre class="lang-js prettyprint-override"><code>// Parent class
  function Animal() { this.type = 'animal' }
  
  // Child class
  function Rabbit(name) { this.name = name }
  
  // I inherit from Animal
  Rabbit.prototype = Object.create(Animal.prototype);
  Rabbit.prototype.constructor = Rabbit; // I want to keep Rabbit constructor too
  
  // I instantiate my Rabbit and am trying to access rabbit.type
  const rabbit = new Rabbit('Bunny');
  rabbit.name // =&gt; Bunny
  rabbit.type // =&gt; undefined. WHY?
  </code></pre>
  
  <p>I know how to solve it and access <code>type</code>, but...</p>
  
  <pre class="lang-js prettyprint-override"><code>// all is the same
  
  // Child class
  function Rabbit(name) {
    Animal.apply(this, arguments); // Just need to add this line in Rabbit class
    this.name = name 
  }
  
  // all is the same
  
  rabbit.name // =&gt; Bunny
  rabbit.type // =&gt; animal
  </code></pre>
  
  <p>...but why it doesn't work in the first example? Is it possible to achieve it without using <code>Animal.apply</code>?</p>