数组去重代码
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 6 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 7 <title>Document</title> 8 </head> 9 <body> 10 let arr= [12,21,12,15,12,21,31,54] 11 function con(arr){ 12 for(let i=0;i<arr.length;i++){ 13 for(let j=i+1;j<arr.length;j++){ 14 if(arr[i]==arr[j]){ 15 arr.splice(j,1) 16 j--; 17 } 18 } 19 } 20 return arr 21 } 22 console.log(con(arr)); 23 </body> 24 </html>
标签:arr,12,21,js,let,数组,进行 From: https://www.cnblogs.com/BlogRegisterqin/p/17219896.html