<script> var arr1 = [1, 1, 2, 2, 3, 3, 4, 4, 6, 1]; var arr2 = []; for(var i = 0; i < arr1.length; i++) { var status = 0; for(var j = 0; j < arr2.length; j++) { if(arr1[i] == arr2[j]){ status = 1; break; } } if(status == 0){ arr2.push(arr1[i]); } } for(var x in arr2){ document.write(arr2[x]+'<br>'); } </script>
数组去重,重新写一个数组。还有记得设定状态status。让他循环过来的时候状态改变为0.