In certain situations, it may happen that we have undefined or generally falsy values in Array structures. For instance when reading and filling data f
The solution with Array.filter will actually keep the array unchanged and create a new array without the undesired items. If you want to clean an array without duplicating it, you can use this:
for (var i = data.length-1; i >= 0; i--) {
if (!data[i]) {
data.splice(i, 1);
}
}