方法一:
遍历数组( for of ),配合indexOf方法
var list = [1,3,9,6,6,9]
function quchong () {
const newList = []
for(let value of list) {
if(newList.indexOf(value) == -1){
newList.push(value)
}
}
return newList
}
console.log(quchong())
方法二:
扩展运算符和 Set 结构相结合,就可以去除数组的重复成员
// 去除数组的重复成员
[...new Set([1, 2, 2, 3, 4, 5, 5])];
// [1, 2, 3, 4, 5]