set集合

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>set集合</title>

</head>
<body>
<div id="ad">

</div>
<div></div>

<script>

    //set声明
    let s = new Set();
    console.log(s,typeof s);

    let s2 = new Set(['小明','小红','小明']);
    console.log(s2);
    //添加元素
    s2.add("小花");
    console.log(s2);
    s2.delete('小明');
    console.log(s2);
    console.log(s2.has('小花'));
    s2.clear();
    console.log(s2);

    let s3 = new Set(['小明','小红','小花']);
    for(let i of s3){
        console.log(i);
    }
</script>
</body>
</html>

相关文章:

  • 2022-03-04
  • 2022-12-23
  • 2022-01-20
  • 2021-06-11
  • 2022-12-23
  • 2021-10-07
  • 2021-05-21
  • 2021-08-12
猜你喜欢
  • 2022-12-23
  • 2021-04-16
  • 2021-12-08
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
相关资源
相似解决方案