title: How can I get all new objects name created from a function constructor?
body: <p>I am working on a javaScript project, building a turned based game, and I have created a function constructor for the Players. </p>
  
  <p>I added a css class for each player, with the same name of the players.</p>
  
  <p>Below I added my js code:</p>
  
  <pre><code>function Player(name, image) {
      this.name = name;
      this.image = image;
  }
  
  var player1 = new Player("kakashi", "ninja.png");
  var player2 = new Player("mightyGuy", "samurai.png");
  
  function checkClass() {
          $.each(classList, function(index, cssClass) {
              if (
                  cssClass === "wall" ||
                  cssClass === "kakashi" ||
                  cssClass === "mightyGuy"
              ) {
                  blocked = true;
              }
          });
      }
  </code></pre>
  
  <p>How could I get all new player.name created from this constructor in order to check if a specific divCell has any player.name class?? </p>
  
  <p>So instead of write cssClass === "kakashi" || cssClass === "mightyGuy" </p>
  
  <p>I would simply write it one time, and automatically it will check all css classes by Player.name.</p>
  
  <p>Update question: 
  This is the way I end up using in my code:</p>
  
  <pre><code>function Player(name, image) {
      this.name = name;
      this.image = image;
  }
  
  var player1 = new Player("kakashi", "ninja.png");
  var player2 = new Player("mightyGuy", "samurai.png");
  
  function checkClass() {
      $.each(classList, function(index, cssClass) {
          if (
              cssClass === "wall" ||
              cssClass == passivePlayer.name
          ) {
              blocked = true;
          }
      });
  }
  </code></pre>
  
  <p>I used this way because I don't need to write any player name by using the var passivePlayer (that could be any player except the activePlayer)</p>