JSFiddle - React, Tailwind, and code Playground

JavaScript

var players = [];

var Player = function(name) {
    this.name = name;
    this.x = 0;
    this.y = 0;
    this.toString = function() {
        return 'player : ' + this.name + ' at ' + this.x + ', ' + this.y;
    };
}

function getPlayerByName(name){
    return players.filter(function(p){
        return p.name.toLowerCase() === name.toLowerCase();
    })[0];
}

players.push(new Player('foo'));

var fetched = getPlayerByName('foo');

console.log(fetched);