var arr = [[1, 2, 3], [3, 4, 5, 5], [6],[7, [8]],[9]] console.log(Array.from(new Set(arr.flat(Infinity).sort((a,b) => a - b))))