1、方法1
let arr = [1,1,2,3,5,4,3,21,2,1,2,1];
let setFromArr = new Set(arr);
let uniArr = Array.from(setFromArr);
// 整合 let uniArr = Array.from(new Set(arr));
2、方法2
let tempArr = []
arr.forEach(item => {
tempArr.indexOf(item) === -1 && tempArr.push(item)
});
3、方法3
let obj = {}
arr.forEach(item => {
obj[item] = 1
});
let uniArr = Object.keys(obj);
4、方法4
arr.filter((item, index) => {
return arr.indexOf(item) === index
})