How can I remove a specific item from an array in JavaScript?
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.
To remove a specific item from an array in JavaScript, you have several methods to choose from. Here are the most common and effective ones:
1. Using splice() Method
The splice() method can be used to remove an item from an array at a specific index.
2. Using filter() Method
The filter() method creates a new array with all elements that pass the test implemented by the provided function. You can use this to exclude the specific item you want to remove.
3. Using findIndex() and splice()
If you want to remove an item based on a condition or a more complex criterion, you can combine findIndex() with splice().
4. Using for Loop and splice()
If you need to remove multiple items or perform additional logic during removal, you can use a for loop.
5. Using reduce() Method
The reduce() method can also be used to build a new array without the specific item.
Summary
- splice() is ideal for removing an item by its index.
- filter() is useful for removing items by value or condition.
- findIndex() + splice() is good for removing items based on more complex conditions.
- reduce() can be used to create a new array excluding the item(s) to be removed.
Each method has its use cases and can be chosen based on your specific needs and the complexity of the condition for removing items from the array.
Related reading
- How do I merge two dictionaries in a single expression in Python?
- How and when to create a suffix link in suffix tree?
- How are distributed queues architectured?
- How are nonblocking data structures possible?
- How do I return the response from an asynchronous call?
- How do I remove a property from a JavaScript object?
- How are Python's Built In Dictionaries Implemented?
- How can a tree be encoded as input to a neural network?

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.