Given an array:
var arr = [1,,2,5,6,,4,5,6,,];
Count how many empty values is has: (length - length after removing the emp
Or, without using js 1.6 filter/foreach, you could cycle it yourself this way:
var arr = [1,,2,5,6,,4,5,6,,]; var emptyElems = 0; for(var i=0, l = arr.length; i < l; i++){ emptyLength += (arr[i] === undefined) ? 1 : 0; } alert(emptyElems); //alerts 3