数组去重的方法
var arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
let newArr = []
Array.from(new Set(arr))
let obj = {}
for (let i = 0; i < arr.length; i++) {
if (!obj[arr[i]]) {
newArr.push(arr[i])
obj[arr[i]] = 1
}
}
for (let i = 0; i < arr.length; i++) {
for (let j = i + 1; j < arr.length; j++) {
if (arr[i] == arr[j]) {
arr.splice(j, 1)
j--
}
}
}
arr.forEach((v) => {
if (newArr.indexOf(v) == -1) newArr.push(v)
})
arr.forEach((v) => {
if (!newArr.includes(v)) newArr.push(v)
})
arr.sort()
arr.forEach((v, i) => {
if (arr[i] !== arr[i - 1]) newArr.push(v)
})
arr.sort()
for (let i = 0; i < arr.length; i++) {
if (arr[i] !== arr[i - 1]) newArr.push(v)
}
for (let i = 0; i < arr.length; i++) {
if (newArr.indexOf(arr[i] == -1)) newArr.push(arr[i])
}
for (let i = 0; i < arr.length; i++) {
if (!newArr.includes(arr[i])) newArr.push(arr[i])
}
arr.filter((v, i) => arr.indexOf(v) == i)
arr.reduce((newArr, v) => {
if (newArr.indexOf(v) == -1) {
newArr.push(v)
}
return newArr
}, [])
arr.reduce((newArr, v) => {
if (!newArr.includes) {
newArr.push(v)
}
return newArr
}, [])
let obj = {}
arr.forEach((v) => {
if (!obj[v]) {
newArr.push(v)
obj[v] = 1
}
})
let newArr = [...new Set(arr)]