13-5、使用Iterator的场合

58 阅读1分钟
<script>
    // 原生可遍历的
    // Array 数组
    // String 字符串
    // Set
    // Map
    // 函数的 arguments 对象
    // NodeList 对象

    // for...of

    // 1.数组的展开运算符
    // console.log(...[1, 2, 3]);
    // console.log(1, 2, 3);
    // console.log(...'str');
    // console.log(...new Set([1, 2, 3]));
    // console.log(...{}); x

    // 2.数组的解构赋值
    // const [a, b] = [1, 2]
    // const [a, b] = [...[1, 2]];
    // const [a, b] = 'hi';
    // const [a, b] = [...'hi'];
    // const [a, b] = new Set([1, 2]);
    // console.log(a, b);

    // 3.Set和Map的构造函数
    // new Set(iterator)
    // new Map(iterator)
</script>