I would like to keep 0
and need to remove undefined
, null
''
,,
from the array. I tried this:
var array = [0, 1, null, 2, "", 3, undefined, 3,,,,,, 4,, 4,, 5,, 6,,,,];
var filtered = array.filter(function (el) {
return el !== null
});
console.log(filtered);
But getting result as : [0, 1, 2, '', 3, undefined, 3, 4, 4, 5, 6]
if I add the condition as return el != null
, still empty space exist and getting error from lint
. how to handle this?
thanks in advance