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