用法一 var set = new Set([1, 2, 3, 4, 2, 8, 4]); //两个2 for (var elem of set) { console.log(elem) // 输出结果 1 2 3 4 8 } 用法二结合.map遍历和for循环 var set = new Set(); [1, 2, 3, 4, 2, 8, 4].map(function (elem) { set.add(elem); //遍历完用add添加至set数组中 }) for (let elem of…