title: Parent/Child class hierachy in nodejs
body: <p><strong>child.js</strong></p>
  
  <pre><code>class Child {
    constructor(){
      this.helloWorld = "Hello World";
    }
    run() {
    }
  }
  
  export default new Child();
  </code></pre>
  
  <p><strong>parent.js</strong></p>
  
  <pre><code>import child from './child.js';
  class Parent {
    constructor() {
       this.child = child;
    }
  }
  
  export default new Parent();
  </code></pre>
  
  <p><strong>index.js</strong></p>
  
  <pre><code>import parent from './parent.js'
  
  console.log(parent.child.helloWorld);  &lt;-- does not throws an error, displays "Hello World"
  console.log(parent.child.run);  &lt;-- throws an error (Cannot read property run from undefined)
  console.log(parent.child.run());  &lt;-- throws an error (Cannot read property run from undefined)
  </code></pre>
  
  <hr>
  
  <p>If I do console.log(parent.child) in index.js, run does not show up, however the property helloWorld does..</p>
  
  <p>How can I have the functions exposed as well? I was hoping to be able to do this to help keep my code a bit more organized, so was going to separate it out into separate classes to help minimize the amount of code in each file.</p>