let list = [12, 2, 3, 4, 5, 6, 7, 8, 3, 2, 32, 32, 32, 32];
方案1;
let newLlist = list.reduce((per, cur) => {
if (per.indexOf(cur) === -1) {
per.push(cur);
}
return per;
}, []);
console.log(newLlist);
方案2:
const newLlist1 = [...new Set(list)]
console.log(newLlist1);
方案3:
const newList2= list.filter((item, index) => list.indexOf(item) === index)
console.log(newList2)
方案4:
const newList3= []
list.forEach((item, index) => {
if (newList3.indexOf(item) === -1) {
newList3.push(item)
}
})
console.log(newList3)