Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
  // define Car class
  class Car {
    constructor(make, model, color, year) {
      this._make = make
      this._model = model
      this._color = color
      this._year = year
    }
    get make() {
      return this._make
    }
    get model() {
      return this._model
    }
    get color() {
      return this._color
    }
    get year () {
      return this._year
    }
    set model (newModel) {
      this._model = newModel
    }
    set color (newColor) {
      this._color = newColor
    }
  }
  // create new "cars" using the Car class as a blueprint
  const myHonda = new Car('Honda', 'Accord', 'gray', '2017')
  console.log(myHonda.make)
  console.log(myHonda.model)
  console.log(myHonda.color)
  // change color
  myHonda.color = `blue`  
  console.log(myHonda.color)
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x