If I have something like
[Object(id:03235252, name:"streetAddress"), Object(id:32624666, name:"zipCode")...]
How can I remove an object from that array that has name set to “zipCode”?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you need to modify the existing Array, you should use
splice().Notice that I’m looping in reverse. This is in order to deal with the fact that when you do a
.splice(i, 1), the array will be reindexed.If we did a forward loop, we would also need to adjust
iwhenever we do a.splice()in order to avoid skipping an index.