I am working with an array of objects, such as a deck of cards:
var deck = [];
deck.push(new Card(suit, rank));
When I try to retrieve a card from the top or bottom of the deck, it works fine:
var card = deck.pop();
var card = deck.shift();
However, if I attempt to get a card from the middle of the deck (imagine this as a hand of cards), like so:
var card = deck.splice(2,1);
The object does not seem to be correctly assigned to the variable and everything turns out undefined. I have researched that splice should return the object being removed - so what could be the issue?