title: How to generate a javascript base class instance from a derived class
body: <p>My application passes instances of a shared base class between two processes, each of which derives separately from the base to specialize behavior. In Process1 I have instances of the derived class from which I need to generate the base class instances to pass to Process2. The following code works but it seems like there should be a more generic way of handling this situation. Any suggestions for how to rewrite generateBase() such that it still works if new attributes are added to base?</p>
  <pre><code>// base.js included in Process1 and Process2
  class base {
      constructor(attribute1, att2) {
          this._a1 = attribute1;
          this._a2 = att2;
      }
  }
  // derived1.js included only in Process1
  class derived1 extends base {
      constructor(a1, a2, a3) {
          super(a1, a2);
          this._a3 = a3;
      }
      generateBase() {
          // base instance to be passed to Process2
          return new base(this._a1, this._a2);
      }                        
      // Other Process1-specific functionality...
  }
  // derived2.js included only in Process2
  class derived2 extends base {
      constructor(a1, a2, a4) {
          super(a1, a2);
          this._a4 = a4;
      }
      // Other Process2-specific functionality...
  </code></pre>