SOURCE

///将数组 arr = [[1,2,3],[3,4,5],[5,6,7,[10,7,9]]]扁平化,排序,去重
let arr = [[1, 2, 3], [3, 4, 5], [5, 6, 7, [10, 7, 9]]]


const flatten = (arr) => {
    let result = []
    arr.forEach((item, i, arr) => {
        if (Array.isArray(item)) {
            result = result.concat(flatten(item))
        } else {
            result.push(arr[i])
        }
    })
    if (result.length < 1)
        return result;

   const minIndex = Math.floor(result.length/2)
   const varArr = result.splice(minIndex,1)
   const minIndexvalue = varArr[0]
   const left =[]
   const right = []
   for (let i=0;i<result.length;i++){
       if(result[i]<minIndexvalue){
           left.push(result[i])
       }else{
           right.push(result[i])
       }
   }
   return flatten(left).concat(minIndexvalue,flatten(right))
}
const set = new Set(flatten(arr))
console.log([...set])
console 命令行工具 X clear

                    
>
console