1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-25 19:22:21 +00:00
This commit is contained in:
Ruan Yifeng 2015-06-15 11:46:44 +08:00
parent a9714aef53
commit e0437efd64

View File

@ -9,14 +9,12 @@ ES6提供了新的数据结构Set。它类似于数组但是成员的值都
Set本身是一个构造函数用来生成Set数据结构。
```javascript
var s = new Set();
[2,3,5,4,5,2,2].map(x => s.add(x))
for (i of s) {console.log(i)}
// 2 3 4 5
// 2 3 5 4
```
上面代码通过add方法向Set结构加入成员结果表明Set结构不会添加重复的值。