ES6 set数据结构演示数组去重

//方法1
const s = new Set();
[2,3,4,4,5,3,6,3,2].forEach(x => s.add(x));
for(let i of s){
    console.log(s);
}
//方法2
const set = new Set([1, 2, 3, 4, 4]);
[...set]

 

posted @ 2017-07-12 15:41  郑庙华  阅读(169)  评论(0编辑  收藏  举报