If I have a javascript array of numbers
[1, 2, 5, 7, 5, 4, 7, 9, 2, 4, 1]
And I want to search through that array and remove a particular number like 4 giving me
[1, 2, 5, 7, 5, 7, 9, 2, 1]
What's the best way to do that
I was thinking it might look like
for(var i = 0; i < myarray.length; i++) {
if(myarray[i] == 4) {
myarray.remove(i)
}
}
But there is no remove
function for an array. Also if I remove an element from the array it messes up my i
unless I correct it.