arr = Array(); arr[0] = 0; arr[3] = 3; arr[4] = 4; for (var i =0; i < arr.length; i++) if (typeof(arr[i]) !== 'undefined') { alert(arr[i]); }