title: JS getters and setters inside a class?
body: <p>I'd like to create a class in JS that uses native getters and setters. I know I can create getters/setters for objects, like so:</p>
  
  <pre><code>var obj = {
      get value(){
          return this._value;
      },
      set value(val){
          this._value = val;
      }
  }
  </code></pre>
  
  <p>I also know that I can use <code>this.__defineGetter__</code> inside a class/function, but MDN says that using <code>__defineGetter__()</code> etc is discauraged. </p>
  
  <p>Is there any better way to add getters and setters to js class than:</p>
  
  <pre><code>function class(){
  };
  
  class.prototype = {
     get value(){
          //....
  
  }
  </code></pre>
  
  <p>?</p>