How can I check the array has empty element or not? Imagine this array,
var arr = [ 'a', 'b', , 'd'];
the arr[2] is undefined
. I want to check this. If the element has empty element, return 'true' or return false. Maybe like this,
function hasEmptyElement(array){
for (var i=0; i<array.length; i++){
if (typeof arr[i] == 'undefined'){
return true;
// and then ?
// should I use double for loop or helper variable?
}
}
}
I confuse how can I do this. Please help me the clevers.