前端中的set, map

Set ES6提供了新的數據結構Set。它相似於數組,可是成員的值都是惟一的,沒有重複的值。web Set函數能夠接受一個數組(或相似數組的對象)做爲參數,用來初始化。數組 const arr = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]; const set = new Set(); arr.forEach(item => set.add(item)); console.lo
相關文章
相關標籤/搜索