给定数组[{GUID,其他属性},...],如何从对象数组中删除特定对象,按对象的属性?
如何通过其GUID(或任何对象属性)从javascript数组中删除特定对象?
我试图使用splice()
,
var index = game.data.collectedItems.indexOf(entityObj.GUID);
if (index > -1) {
game.data.collectedItems.splice(index, 1);
}
这不会起作用,因为我不能直接在阵列中确定的价值,因为这样的:
var array = [2, 5, 9];
var index = array.indexOf(5);
如下所示: How do I remove a particular element from an array in JavaScript?
http://stackoverflow.com/questions/6485127/how-to-delete-unset-the-properties-of-a-javascript-object – 2015-02-08 07:20:13
HTTP ://stackoverflow.com/questions/1596782/how-to-unset-a-javascript-variable – 2015-02-08 07:20:43
http://stackoverflow.com/questions/208105/how-to-remove-a-property-from-a-javascript -object – 2015-02-08 07:21:04