title: Uncaught TypeError: Cannot set property playerNo of # which has only a getter on line 4
body: <p>I'm moving from using the hacky JavaScript classes of old (functions and prototypes) to the new ES6 classes.</p>
  
  <p>I'm probably doing something stupid but I'm not sure why I'm not allowed to do this:</p>
  
  <pre><code>class Player{
      constructor(playerNo){
          this.playerNo = playerNo;
      }    
      get playerNo(){
          return this.playerNo;
      }
  
      set cards(playersCards){
          this.cards = playersCards;
      }
      get cards(){
          return this.cards;
      }
  }
  
  var steve = new Player(1);
  </code></pre>
  
  <p>It gives me the error: <code>Uncaught TypeError: Cannot set property playerNo of # which has only a getter on line 4</code></p>
  
  <p>So, I tried the below:</p>
  
  <pre><code>class Player{
      constructor(playerNo){
          this.playerNo = playerNo;
      }   
      set playerNo(no){
          this.playerNo = no;
      }
      get playerNo(){
          return this.playerNo;
      }
  
      set cards(playersCards){
          this.cards = playersCards;
      }
      get cards(){
          return this.cards;
      }
  }
  
  var steve = new Player(1);
  </code></pre>
  
  <p>Which gives me: <code>Uncaught RangeError: Maximum call stack size exceeded on line 6</code> (which is the line <code>this.playerNo = no;</code>).</p>
  
  <p>Any ideas?</p>