Why is the if condition failing? Take the array, filter out every item and where the item is strictly equal to null, then splice the element at that particular index to remove one item which is null. But it keeps one null in the array. Why is this happening?
let a = [null, null, null, "a"];
a.filter(function(v,i){
if (v===null){
a.splice(i, 1)
}
console.log(a);// gives [null, "a"]
})