数组去重
// 将数组降维 数组降重
function resetArray(arr, newArr){
arr.forEach(item => {
if (toString.call(item) === "[object Array]") {
resetArray(item, newArr);
} else {
newArr.push(item);
}
})
}
// 将数组去重
function uniArr(arr) {
var newArr = [];
resetArray(arr, newArr);
console.log([...new Set(newArr)]);
}
arr = [1, 2, 3, [1, 2, [3, 4]], [1]]
uniArr(arr);