js数组去重
1:[...new Set(arr)] Array.from(new Set(arr))
2:
1 function uniq(arr){ 2 let result=[] 3 for(let i=0;i<arr.length;i++){ 4 if(result.indexOf(arr[i]) == -1){ 5 result.push(arr[i]) 6 } 7 } 8 return result 9 }
1:[...new Set(arr)] Array.from(new Set(arr))
2:
1 function uniq(arr){ 2 let result=[] 3 for(let i=0;i<arr.length;i++){ 4 if(result.indexOf(arr[i]) == -1){ 5 result.push(arr[i]) 6 } 7 } 8 return result 9 }