<script>
//第一种
let arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
let newArr = [...new Set(arr)]
console.log(newArr)
//第二种方法
let newarr = arr.filter((item, index, arr) => arr.indexOf(item, 0) === index)
console.log(newarr)
</script>
<script>
//第一种
let arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
let newArr = [...new Set(arr)]
console.log(newArr)
//第二种方法
let newarr = arr.filter((item, index, arr) => arr.indexOf(item, 0) === index)
console.log(newarr)
</script>