String split returns an array with more elements than expected (empty elements)

You could add a filter to exclude the empty string.

var string = 'a,b,c,d,e:10.';
var array = string.split ('.').filter(function(el) {return el.length != 0});

Leave a Comment