js delete array ''

function removeEmpty(arr) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] == "" || typeof (arr[i]) == "undefined") {
arr.splice(i, 1);
i = i - 1; // i - 1, since the position of empty elements in the array subscript 2, then remove air, fill the elements behind the forward position to
}
}
return arr;
};
removeEmpty(stationall);
 
This is the case, when the merger if the two arrays are free, there will be behind the array has '' This leads to upload data failed. This method can be used to array 'filtered

Guess you like

Origin www.cnblogs.com/lq2333/p/11209677.html