const getDupeList = (arr) => { return Array.from(new Set(arr.filter((v, i, array) => { return !(array.indexOf(v) === i); }))); } console.log(getDupeList([1, 2, 3, 1, 2, 4, 5, 1])); //-> [ 1, 2 ]
牌語備忘録 -pygo
const getDupeList = (arr) => { return Array.from(new Set(arr.filter((v, i, array) => { return !(array.indexOf(v) === i); }))); } console.log(getDupeList([1, 2, 3, 1, 2, 4, 5, 1])); //-> [ 1, 2 ]