数组去重
let arr=[1,2,3,2,3,2,3,4,5,5,6];
let arr1=[];
for(var i=0;i<arr.length;i++;){
if(arr1.indexOf(arr[i])==-1){
arr1.push(arr[i])
}
}
console.log(arr1);
let arr = ['2021年','2022年','2021年','2022年']
let result = arr.reduce((prev, item) => {
if (!prev.includes(item)) {
prev.push(item)
}
return prev
}, [])
nameList = result;
function fn(arr) {
return arr.filter((item, index, arr) => arr.indexOf(item) === index)
}
var arr = [1,3,3,4,2,1,1,5,2]
var newArr = new Set(arr)
let newArr = this.tableData.filter((currentValue, currentIndex, sourceArr) => {
return sourceArr.findIndex(el => el.khxId == currentValue.khxId) === currentIndex
})
console.log(newArr);