Store ES6 class in variable and instance it through Object.Create
<p>I'm currently needing to pass a <strong>class</strong> through a variable to a function which dynamically calls their constructor and so on. Short example:</p>

<pre><code>class MyClass {
  constructor ($q) {
    console.log($q);
  }

  expose () {
    return {};
  }
}

const myclass = function () {
  // My concern is this ------.
  // I need to pass it        |
  // as a variable           \|/
  //                          '
  let obj = Object.create(MyClass.prototype);
  obj.constructor.apply(obj, arguments);
  return {}; // other stuff goes here
};
myclass.$inject = ['$q'];
export {myclass};
</code></pre>

<p>My idea is to pass MyClass as a variable, to have it this way:</p>

<pre><code>const myclass = function (classVariable) {
  let obj = Object.create(classVariable.prototype);
  obj.constructor.apply(obj, arguments);
  return {}; // other stuff goes here
};
</code></pre>

<p>So that I can call it like <code>let newclass = myclass(MyClass);</code>. This way if I have different classes (MyClass2, MyClass3, and so on) I don't have to repeat code in each file. If I try to do it this way though, Chrome throws an error saying that it cannot use a class as variable or something like that. </p>

<p>So, what would be the best approach to do this and avoid repeating code? it's actually a redesign I'm working on to avoid the copy-paste disaster made by someone else I need to fix. Thanks in advance!</p>