Try this. Pass it your array and it will return with empty elements removed. *Updated to address the bug pointed out by Jason
function removeEmptyElem(ary) {
for (var i = ary.length - 1; i >= 0; i--) {
if (ary[i] == undefined) {
ary.splice(i, 1);
}
}
return ary;
}