思路:数组转set集合,set集合再转为数组

let array = Array.from(new Set([1, 1, 1, 2, 3, 2, 4]));

console.log(array); // => [1, 2, 3, 4]

相关文章: