可以使用Set和Array.from()来实现数组去重,然后使用sort()方法进行排序。
const arr = [3, 1, 2, 2, 3]; const uniqueArr = Array.from(new Set(arr)).sort((a, b) => a - b); console.log(uniqueArr); // [1, 2, 3]
其中,关键词包括了Set、Array.from()、sort()方法,这些都是实现数组去重并排序的重要方法。