I have read this question:
Deleting array elements in JavaScript - delete vs splice
And it appears that both splice and delete require an index of the element in order to remove, so how can I easily find the index when I have the value?
For example if I have an array that looks like this:
["test1", "test2", "test3"]
and I want to remove test2. The process I am using right now, which I'm hoping isn't the correct way to do it, is using $.each
checking the value of each element in the array, maintaining a counter through the process (used as the index reference) and if the value is equal to "test2", then I have my index (in form of the counter) and then use splice to remove it.
While the array grows larger, I would imagine this would be a slow process, but what alternatives do I have?