方式一 使用filter方法,如下: const array = [5,4,7,8,9,2,7,5]; array.filter((item,idx,arr) => arr.indexOf(item) === idx); 方式二 使用set,如下: const nonUnique = […new Set(array)]; // Output: [5, 4, 7, 8, 9, 2]