Introduction
In JavaScript, we may need to remove a specific item from an array.
In this post, we'll learn how to remove an item from an array.
How to remove a specific item from an array
In vanilla JS, to remove a specific item from an array we need to find the index of that element using the indexOf
method, and then remove that index with the splice
method.
Conclusion
To remove a specific item from an array in vanilla JS, we use the indexOf
and splice
methods.
In ES6
we can use array.filter(...) method to remove items from an array.
In jQuery
we can use array.grep(...) method to remove item/items from an array.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}