JavaScript 组数去重demo

 1 <!doctype html>  
 2 <html>  
 3 <head>  
 4 <meta charset="utf-8">  
 5 <title>JavaScript 组数去重demo</title>  
 6 <script>  
 7 window.onload = function(){  
 8     var arr = [1,2,3,4,5,6,1,2,'aa',11];  
 9       
10     for(var i=0; i<arr.length; i++ ){  
11         for(var j =i+1; j<arr.length; j++){  
12             if(arr[i]==arr[j]){  
13                 arr.splice(j,1);  
14                 j--;  
15                 }  
16             }  
17         }  
18     alert(arr);  
19 }  
20 </script>  
21 </head>  
22 <body>  
23 </body>  
24 </html>  

 

posted @ 2018-01-26 14:16  ysx_小鱼  阅读(121)  评论(0编辑  收藏  举报