集合(Set)对象允许你存储任意类型的唯一值(不能重复),无论它是原始值或者是对象引用,Set对象是值的集合,你可以 按照插入的顺序迭代它的元素。 Set中的元素只会出现一次,即 Set 中的元素是唯一的
new Set([iterable]);
var mySet = new Set();
mySet.add(1); mySet.add(5); mySet.add("set demo");
console.log(mySet.has(1)); console.log(mySet.has(3)); console.log(mySet.has(5));
console.log(mySet.size);
mySet.delete(5);
本文出自 “素颜” 博客,请务必保留此出处http://suyanzhu.blog.51cto.com/8050189/1902713
原文:http://suyanzhu.blog.51cto.com/8050189/1902713