美文网首页
02_08.for_of

02_08.for_of

作者: Robyn_Luo | 来源:发表于2017-11-13 17:02 被阅读0次
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <li>111</li>
    <li>222</li>
    <li>333</li>
    <li>444</li>
    <script>
    // for of语句是es6新增的循环语句,
    // 作用是用来遍历数组以及内置的伪数组结构中的值, 另外Set Map也支持

    let arr = [ 11, 22, 33 ];
    for(let v of arr) {
        console.log(v);
    }

    let lis = document.querySelectorAll('li');
    for(let li of lis) {
        console.log(li);
    }

    let set = new Set([2, 4, 5, 2]);
    for(let v of set) {
        console.log(v);
    }
    </script>

相关文章

网友评论

      本文标题:02_08.for_of

      本文链接:https://www.haomeiwen.com/subject/uswzmxtx.html