Easy get and set

class Counter{
  
  constructor(){
    this.counterValue = 0;
  }
  
  get counter() {
    return this.counterValue;
  }
  
  set counter(val){
    this.counterValue = val;    
  }
}

let c = new Counter();

console.log(c.counter);
c.counter = 4;
console.log(c.counter);


code