![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/4d02a107c4ccfa82d2a6e2e242ae0544.png)
1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
let s=new Set(['语文','数学'])
let s2=new Set(['html','html','css','js'])
console.log(s2);
console.log(s2.size);
console.log(s2.add('es6'));
console.log(s2.delete('css'));
console.log(s2);
console.log(s2.has('html'));
console.log(s2.clear());
console.log(s2);
for(let v of s){
console.log(v);
}
</script>
</body>
</html>
2.集合实践
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
let arr=[1,1,2,3,4,5,5,5,7]
let result=[...new Set(arr)]
let arr2=[3,4,5,5]
let s2=new Set(arr2)
let result2=[...new Set(arr)].filter(item=>s2.has(item))
console.log(result2);
let union=[...new Set([...arr,...arr2])]
console.log(union)
let result3=[...new Set(arr)].filter(item=>!s2.has(item))
console.log(result3);
</script>
</body>
</html>