02_08.for_of

2017-11-13  本文已影响0人  Robyn_Luo
<!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>
上一篇 下一篇

猜你喜欢

热点阅读