1.对数组遍历
<script>
var arr=[1,2,1,2,4,6];
var res=[];
arr.forEach(item=>{
if(!res.includes(item)){
res.push(item);
}
})
console.log(res);
</script>
set方法
<script>
var arr=[1,2,3,4,3,2];
var s=new Set(arr);
console.log(s);
console.log([...s]);
</script>