标签:ack html splice ice [] nbsp script arp color
1 // 方法一 2 <script> 3 var arr1 =[1,2,2,2,3,3,3,4,5,6]; 4 var arr2 = []; 5 for(var i=0;i<arr1.length;i++){ 6 if(arr2.indexOf(arr1[i])<0){ 7 arr2.push(arr1[i]); 8 } 9 } 10 document.write(arr2); 11 </script>
//方法二 <script> var arr=[1,2,3,1,2,3,4,6,89,4,3,23,45,67]; for(var i=0;i<arr.length;i++){ for(var j=i+1;j<arr.length;j++){ if(arr[i]==arr[j]){ arr.splice( j, 1 ); j--; } } } alert(arr); </script>
标签:ack html splice ice [] nbsp script arp color
原文地址:http://www.cnblogs.com/miaoxiaojiao/p/7019387.html