第二十四节 JavaScript中的数组去重实例
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 <script type="text/javascript"> 7 var aList01 = [1,1,2,2,3,3,4,4,5,5,6,6]; 8 var aList02 = []; 9 var iLen = aList01.length; 10 for(var i=0;i<iLen;i++){ 11 if(aList01.indexOf(aList01[i])==i){ 12 aList02.push(aList01[i]); 13 } 14 15 } 16 alert(aList02); 17 </script> 18 </head> 19 <body> 20 21 </body> 22 </html>