去重 阳焰觅鱼 2022-03-06 84 阅读1分钟 function noRepeat(arr: any[]) { const hash = new Map(); arr.forEach((item) => { if (hash.has(item)) return; hash.set(item, true); }); return [...hash.keys()]; } const arr = noRepeat([1, 1, 1, 1, 2, 2, 2, 3]); console.log(arr);