title: Conditions in class constructor javascript
body: <p>I have this code </p>
  
  <pre><code>class Person{
    constructor(person){
      this._name=person._name;
      this._age=person._age;
    }
  }
  
  class Employee extends Person{
    constructor(person){
      if(person instanceof Person){
      super(person);
      }else{
         throw 'passed object is not a valid person object';
      }
    }
  }
  
  let emp=new Employee({_name:'Uday',_age:24});
  console.log(emp);
  </code></pre>
  
  <p>I want to call super(person) only when I get valid person object. I'm getting this error <code>this hasn't been initialised - super() hasn't been called</code> in <a href="http://babeljs.io/repl/#?babili=false&amp;evaluate=true&amp;lineWrap=true&amp;presets=env&amp;targets=&amp;browsers=&amp;builtIns=false&amp;code=class%20Person%7B%0A%20%20constructor(person)%7B%0A%20%20%20%20this._name%3Dperson._name%3B%0A%20%20%20%20this._age%3Dperson._age%3B%0A%20%20%7D%0A%7D%0A%0Aclass%20Employee%20extends%20Person%7B%0A%20%20constructor(person)%7B%0A%20%20%20%20if(person%20instanceof%20Person)%7B%0A%20%20%20%20super(person)%3B%7D%0A%20%20%7D%0A%7D%0A%0Alet%20emp%3Dnew%20Employee(%7B_name%3A&#39;Uday&#39;%2C_age%3A24%7D)%3B%0A%0Aconsole.log(emp)%3B&amp;experimental=false&amp;loose=false&amp;spec=false&amp;playground=true" rel="nofollow noreferrer">babeljs.io</a>. How to make sure I pass only valid <code>person</code> object to super class?</p>