// 数组扁平化 去重 排序
const arr = [1, [3, 5, 2], [5, [7, [8, 2]]]]
Array.prototype.myFlat = function() {
return this.reduce((acc, curr) => {
return acc.concat(Array.isArray(curr) ? curr.myFlat() : curr)
}, [])
}
Array.prototype.unique = function() {
let map = {}
return this.filter(item => map.hasOwnProperty(item) ? false : (map[item] = true))
}
const sort = (a, b) => a - b
console.log(arr.myFlat().unique().sort(sort))