示例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>JavaScript set</title>
<link rel="stylesheet" href="">
</head>
<body>
<script type="text/javascript">
var mySet = new Set();
mySet.add(1);
mySet.add(5);
mySet.add("set demo");
for(let item of mySet.keys()){
console.log(item);
}
for(let item of mySet.values()){
console.log(item);
}
for(let [key,value] of mySet.entries()){
console.log(key);
}
var myArr = Array.from(mySet);
for(var i in myArr){
console.log(myArr[i]);
}
mySet.forEach(function(value){
console.log(value);
});
</script>
</body>
</html>