數組去重的幾種方法

數組去重 1.利用indexOf遍歷數組去重javascript function unique(arr){ const res = [] arr.forEach(item => { if (res.indexOf(item) < 0){ res.push(item) } }) return arr } 新建一個空的結果數組
相關文章
相關標籤/搜索