Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript array remove empty strings

// an empty space between two commas in an array is categorized as a null value
var array = [0, 1, null, 2, "", 3, undefined, 3,,,,,, 4,, 4,, 5,, 6,,,,];
// copy the following code snippet and use it anywhere in your own code
var filtered = array.filter(function (el) {
  return el != null;
});

console.log(filtered);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #array #remove #empty #strings
ADD COMMENT
Topic
Name
1+4 =