title: How to work with private variables in ES6?
body: <p>In ES5, you could emulate a class with private and public variables like this:</p>
  
  <p><strong>car.js</strong></p>
  
  <pre><code>function Car() {
      // using var causes speed to be only available inside Car (private)
      var speed = 10;
  
      // public variable - still accessible outside Car
      this.model = "Batmobile";
  
      // public method
      this.init = function(){
  
      }
  }
  </code></pre>
  
  <p>But in ES6, you can no longer declare vars outside the constructor, making it actually HARDER to work with classes in a OOP way!? </p>
  
  <p>You can declare variables in the constructor using this, but that makes them public by default. This is very weird since ES6 <strong>DOES</strong> have a get / set keyword!</p>
  
  <pre><code>class Vehicle {
      constructor(make, year) {
          // the underscore is nice, but these are still public!
          this._make = make;
          this._year = year;
      }
  
      // get and set can be handy, but would make more sense
      // if _make and _year were not accessible any other way!
      get make() {
          return this._make;
      }
  
      get year() {
          return this._year;
      }
  }
  </code></pre>