Given array [{GUID, other properties}, ...],
How can I remove a specific object from a javascript array by its GUID (or any object property)?
I'm trying to use splice()
,
var index = game.data.collectedItems.indexOf(entityObj.GUID);
if (index > -1) {
game.data.collectedItems.splice(index, 1);
}
This won't work because I can't directly identify the value in the array, as such:
var array = [2, 5, 9];
var index = array.indexOf(5);
Shown here: How do I remove a particular element from an array in JavaScript?