Answers for "remove empty from array in javascript"

6

Javascript remove empty elements from array

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);
Posted by: Guest on July-25-2019
0

js filter to remove empty string in array.

var s = [ '1,201,karthikeyan,K201,HELPER,[email protected],8248606269,7/14/2017,45680,TN-KAR24,8,800,1000,200,300,Karthikeyan,11/24/2017,Karthikeyan,11/24/2017,AVAILABLE\r',
  '' ]
var newArr = s.filter(function(entry) { return entry.trim() != ''; })

console.log(newArr);
Posted by: Guest on May-19-2021

Code answers related to "remove empty from array in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language