1let array = [0, 1, null, 2, 3];
2
3function removeNull(array) {
4return array.filter(x => x !== null)
5};
1var data = [42, 21, undefined, 50, 40, undefined, 9];
2
3data = data.filter(function( element ) {
4 return element !== undefined;
5});
1var colors=["red","blue",,null,undefined,,"green"];
2
3//remove null and undefined elements from colors
4var realColors = colors.filter(function (e) {return e != null;});
5console.log(realColors);
1// Removing null,undefined,0 value from array
2
3const data = ['Abc',0,null,"Hello",undefined]
4
5const filterData = data.filter(Boolean);
6
7console.log(filterData)