var origin = [, 8, 0, 2, , 9]; var result = []; for (var i = 0; i < origin.length; i++) { if ( i in origin ) { result.push(origin[i]); } } alert('origin = ' + origin); alert('result = ' + result);