I have a javascript function which delete object from object array:
function RemoveFilter(filtArray,filtName) {
var filtCount = filtArray.length;
...
...
for (var i = 0; i < filtCount; i++) {
var filter = filtArray[i];
if (filter != undefined && filter.name == filtName) {
delete filtArray[i];
}
}
...
...
}
It's works but I got a big problem. Instead of removing object completelly, it leaves undefined on its place (that why I have filter != undefined
in my if).
So basically, if I am adding something after removal, I have not only new values but also those undefiled, and array is growing.
Probably my choise of object removing is poor but, how can I deal with this problem?
Considering that filtArray[i].remove
not working at all.