title: Create ES6 class from a function
body: <p>I'm trying to explore using ES6 classes instead of how we do it currently, using the Function.prototype means. Currently our API looks like:</p>
  
  <pre><code>var myclass = createClass('MyClass', {
      test : function() {}
  });
  </code></pre>
  
  <p>We iterate through the object and apply those properties onto the Function that we return, basically a prettier way than to do so that it's more inline with other programming languages of sorts:</p>
  
  <pre><code>function MyClass() {}
  
  MyClass.prototype.test = function() {};
  </code></pre>
  
  <p>We also cache the class onto an object where name is the key and the function is the value for use throughout our application. The class name can be namespaced so you can have <code>My.Cls</code> and it will split by the period and then cache it onto the manager but it also can be retrieved via <code>window.My.Cls</code>.</p>
  
  <p>Looking into ES6 classes, I don't see how I can keep the <code>createClass</code> function. Would love something like:</p>
  
  <pre><code>function createClass(name, config) {
      return class name config;
  }
  </code></pre>
  
  <p>I didn't expect it to work and it doesn't.</p>
  
  <p>Two issues I have here:</p>
  
  <ol>
  <li>How can I create a class using a variable as the class name?</li>
  <li>How can I create a class and assign the properties via the config object argument?</li>
  </ol>
  
  <p>Not sure this would be possible. We don't plan on keeping the <code>createClass</code>, we hope to keep it for now and upgrade our legacy "classes". I'd like to start using ES6 classes but not break the whole app for however long it'll take us to fully upgrade.</p>