reduce 數組去重

let arr = [2,1, 2, 3, 4, 4, 1,2]console let newArr = arr.reduce((pre, cur) => {co console.log(pre)let if (!pre.includes(cur)) {new return pre.concat(cur)return } else { return pre } }, []) console.log
相關文章
相關標籤/搜索