// 关于数组去重
const list = [3, 3, 4, 5, 2, 3, 34, 45, 38, 19, 34, 90, 3, 3, 6, 7, 8,]
// 使用filter
function run (list) {
const list2 = []
list.filter(item => {
if (!list2.includes(item)) {
list2.push(item)
}
})
return list2
}
console.log(run(list))
// 使用map
function run2 (list) {
const map = new Map()
list.map((item, index) => {
map.set(item, index)
})
const list2 = []
map.forEach((value, key) => {
list2.push(key)
// console.log(key)
})
return list2
}
console.log(run2(list))