title: Create a Class with mandatory and optional properties
body: <p>I am defining a ECMAScript 6 class for my Express web application. It has a mandatory property and a few optional properties. The mandatory field needs to be assigned during class construction while the optional ones don't.</p>
  
  <p>The optional properties only require setting on demand.</p>
  
  <pre><code>class Item{
  
      constructor(mandatoryField) {
          this._mandatoryField = mandatoryField;
          this._optionalField1 = undefined;
          this._optionalField2 = undefined;
          this._optionalField3 = undefined;
      }
  
      get mandatoryField() {
          return this._mandatoryField;
      }
  
      set mandatoryField(newVal){
          if(newVal){ 
              this._mandatoryField = newVal;
          }
      }
  
      get optionalField1() {
          return this._optionalField1;
      }
  
      set optionalField1(newVal){
          if(newVal){ 
              this._optionalField1 = newVal;
          }
      }
  
      get optionalField2() {
          return this._optionalField2;
      }
  
      set optionalField2(newVal){
          if(newVal){ 
              this._optionalField2 = newVal;
          }
      }
  
      get optionalField3() {
          return this._optionalField3;
      }
  
      set optionalField3(newVal){
          if(newVal){ 
              this._optionalField3 = newVal;
          }
      }
  }
  
  var item1 = new Item("mandVal");
  item1.mandatoryField;    // access the mandatory property
  item1.optionalField1("optVal");    // set the optional property
  item1.optionalField1;    // access the optional property
  </code></pre>
  
  <p>Is there any problem with the declaration as above? How can I enable the optional properties to have default values in the class declaration?</p>