Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
24
rated 0 times [  31] [ 7]  / answers: 1 / hits: 37961  / 12 Years ago, fri, january 18, 2013, 12:00:00

Possible Duplicate:

Delete from array in javascript






I have the following JSON object:



[id:84,id:92,id:123,id:2353]


How would I go about removing the item which the value is 123 using javascript?



or if I formatted the json as



[84, 92, 123, 2353]


How would it be removed in this case?


More From » jquery

 Answers
8

Assume you have this:



var items  = [{ id: 84 }, { id: 92 }, { id: 123 }, { id: 2353 }];

var filtered = items.filter(function(item) {
return item.id !== 123;
});

//filtered => [{ id: 84 }, { id: 92 }, { id: 2353 }]

[#80777] Thursday, January 17, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kinsleyashlynnh

Total Points: 64
Total Questions: 119
Total Answers: 98

Location: Burundi
Member since Sat, Aug 21, 2021
3 Years ago
;