1let array = [0, 1, null, 2, 3];
2
3function removeNull(array) {
4return array.filter(x => x !== null)
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);
1var array = [0, 1, null, 2, "", 3, undefined, 3,,,,,, 4,, 4,, 5,, 6,,,,];
2
3var filtered = array.filter(function (el) {
4 return el != null;
5});
6
7console.log(filtered);