O'Reilly logo
  • Anna Emson thinks this is interesting:

    class Car { 
      constructor(model, year){ 
        this.model = model; 
        this.year = year; 
      } 
      get model(){ 
        return this.model 
      } 
   
      calculateCurrentValue(){ 
        return "7000" 
      } 
    } 
    const fiesta = new Car('Fiesta','2010') 
    console.log(fiesta.model) 

From

Cover of Object-Oriented JavaScript - Third Edition

Note

Uncaught TypeError: Cannot set property model of #<Car> which has only a getter at new Car (<anonymous>:3:20) at <anonymous>:1:21