chen55555

用for循环取数组的值

第一种

    <script>
        // 用for循环取数组的值
        function f1(){
            let a = [\'\', \'\', \'\', \'\', \'\'];
            for (let item in a){
                // console.log(a[item]);
                let s = a[item] + "<br/>";
                document.write(s);
        }
        }
        setInterval(\'f1();\', 500);
    <script/>

第二种

<script>
        function f1(){
            let a = [\'\', \'\', \'\', \'\', \'\'];
            for (let item=0; item<a.length; item++){
                // console.log(a[item]);
                let s = a[item] + "<br/>";
                document.write(s);
        }
        }
        setInterval(\'f1();\', 500);
</script>

 

 

用for循环取对象的值

    <script>
        //用for循环取对象的值
        function f1(){
            let a = {\'k1\':\'\', \'k2\':\'\', \'k3\':\'\', \'k4\':\'\',\'k5\':\'\'};
            for (let item in a){
                // console.log(a[item]);
                let s = a[item] + "<br/>";
                document.write(s);
        }
        }
        setInterval(\'f1();\', 500)
    </script>

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2021-09-08
  • 2021-12-15
猜你喜欢
  • 2021-12-25
  • 2022-12-23
  • 2021-12-15
  • 2022-02-06
  • 2021-12-15
相关资源
相似解决方案