title: Javascript Array of Instances of a class
body: <p>In JS, I have a class called <code>player</code> which is:</p>
  <pre><code>class player {
      constructor(name) {
          this.name = name;
      }
  }
  </code></pre>
  <p>and I have two instances of it, called <code>PL1</code> and <code>PL2</code>:</p>
  <pre><code>const PL1 = new player ('pl1name');
  const PL2 = new player ('pl2name');
  </code></pre>
  <p>I also have an array called <code>PLAYERS</code>:</p>
  <pre><code>let PLAYERS = [];
  </code></pre>
  <p>now, the question is how can I create an array with all of the instances of the class <code>player</code>?</p>
  <p>I know I can manually do this with <code>PLAYERS.push(PL</code><strong>n</strong><code>)</code>; but I'm looking for a way to do this somehow automatically. Is there a built-in function? Should I use a loop?</p>