title: Merging 2 classes
body: <p>I want to merge 2 classes or add all methods from 1 class to another. In the future It will be the more classes than just a (ContainerClient) class.</p>
  
  <p><code>Client</code> and <code>ContainerClient</code></p>
  
  <p>I tried this but I think It can be done even easier.</p>
  
  <pre><code>for (var a of Object.getOwnPropertyNames(ContainerClient.prototype)) {
    Client.prototype[a] = ContainerClient.prototype[a];
  }
  </code></pre>
  
  <p>Principle: <code>ContainerClient</code> depends on <code>Client</code></p>
  
  <h2>Data.js</h2>
  
  
  
  <pre class="lang-js prettyprint-override"><code>class Data {
    constructor () {
  
    }
  }
  </code></pre>
  
  <h2>Client.js</h2>
  
  <pre class="lang-js prettyprint-override"><code>class Client extends Data {
    me () {
      return {
        id: '1',
      };
    }
  }
  </code></pre>
  
  <h2>Container.js</h2>
  
  <pre class="lang-js prettyprint-override"><code>class Container extends Data {
    containers () {
      return [
        {
          clientId: '1',
          id: '2',
        },
        {
          clientId: '2',
          id: '3',
        },
      ];
    }
  }
  </code></pre>
  
  <h2>ContainerClient.js</h2>
  
  <pre class="lang-js prettyprint-override"><code>class ContainerClient extends Data {
    containers () {
      return {
        clientId: '1',
        id: '2',
      };
    }
  }
  </code></pre>
  
  <h1>--> Client.js before <code>export</code> &lt;--</h1>
  
  <pre class="lang-js prettyprint-override"><code>// --&gt; HERE &lt;--
  for (var a of Object.getOwnPropertyNames(ContainerClient.prototype)) {
    Client.prototype[a] = ContainerClient.prototype[a];
  }
  
  // -&gt; [ 'constructor', 'me', 'containers' ]​​​​​ 
  console.log(Object.getOwnPropertyNames(Client.prototype));
  </code></pre>
  
  <h2>index.js</h2>
  
  <pre class="lang-js prettyprint-override"><code>const client = new Client();
  const container = new Container();
  
  // -&gt; { clientId: '1', id: '2' }​​​​​ 
  console.log(client.containers());
  </code></pre>