I came across a situation where I have to remove multiple items from an array object. There are multiple ways to remove a specific item from an array. Now we will see some of the easiest techniques to do this task.
As you can see in above code ,I have created an array and I’m using the .push() method to push elements to the array.Now I want to delete or remove a specific element from an array.
For that i have create a global generic .DeleteItem() function so that you can use it like .push() method
Something like this:
This function removes all of the items from the array that match with arguments.
Using using indexOf and splice
Using Move on Trick
it works better if you only want to remove or delete one occurrence of an element.
There are many excellent ways to achieve this task, you can choose one of them for your solution.