title: JavaScript get/set properties, both must be defined for inherited classes
body: <p>I stumbled onto a peculiarity with JavaScript, not sure if it is by design or a bug in the Chrome browser. If the base class has both a get and set property accessor with the same name, the inherited class can not override just one, it must override both.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class Class1 {
    constructor() {
      this._item = 1;
    }
  
    set item(value) {
      this._item = value;
    }
  
    get item() {
      return this._item;
    }
  }
  
  class Class2 extends Class1 {
    constructor() {
      super();
      this._item = 2;
    }
  
    set item(value) {
      this._item = value;
    }
  }
  
  let c1 = new Class1();
  let item1 = c1.item; // item1 is 1
  console.log(item1);
  let c2 = new Class2();
  let item2 = c2.item; // item2 should be 2, but is undefined
  console.log(item2);</code></pre>
  </div>
  </div>
  </p>