代码如下:
<script>
var arr = [1,1,2,2,3,3,4,4,5,5];
var Newarr = new Set(arr);
console.log(Newarr);
console.log(...Newarr);
</script>
结果如下:
数组去重.png
干一行,爱一行,学到老,活到老~
<script>
var arr = [1,1,2,2,3,3,4,4,5,5];
var Newarr = new Set(arr);
console.log(Newarr);
console.log(...Newarr);
</script>
干一行,爱一行,学到老,活到老~