On websocket event I'm trying to slice an array inside an associative array of object but it doesn't work

Viewed 73

I have an objects containing property playerData which can look like this for example:

this.playerData = {"username1":{"hand":["AD,"JD","2D","3H"],"points":0}}

on a websocket event I'm running a function trying to slice the hand array like this. GAMES_LIST[gameId] = associativ array where key is id and value is instance of object constructor. handIndex is a number which is an integer.

socket.on('event',function(data){
 GAMES_LIST[data.gameId].playerData[data.someUsername].hand.slice(data.handIndex,1);
});

The slice doesn't work and the array is unaffected. When I do it outside the function like this it works.

var game = gameConstructor(some params...);
game.playerData[someUsername].hand.slice(handIndex,1);

Getting no errors. Gone through everything rigorously but can't seem to find the problem. Had to leave out a lot of code that would be to complicated to get a grasp of quickly but have simplified that which is relevant. Would greatly appreciate some help. Thanks in Advance.

0 Answers
Related