Example 1: Javascript remove empty elements from array
var colors=["red","blue",,null,undefined,,"green"];
var realColors = colors.filter(function (e) {return e != null;});
console.log(realColors);
Example 2: php remove empty values from array
$array = array_filter($array, function($a) {return $a !== "";});
$array = array_filter($array, function($a) {
return trim($a) !== "";
});
Example 3: remove empty values from array javascript
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);
Example 4: array remove empty entrys js
const filterArray=(a,b)=>{return a.filter((e)=>{return e!=b})}
let array = ["a","b","","d","","f"];
console.log(filterArray(array,""));
Example 5: remove null values from array php
array_filter