数组去重
function removeDup(arr){
const ret = []
for(let i = 0; i < arr.length; i ++){
if(ret.indexOf(arr[i]) < 0){
ret.push(arr[i])
}
}
return ret
}
function Uniq(arr = []) {
return arr.reduce((t, v) => t.includes(v) ? t : [...t, v], []);
}
Array.from(new Set(arr))
[...new Set(arr)]
最后更新于