JS-04-流程控制和循环

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
    <script>
        //常规的for,while循环都是一样的
        //此处只记录for...in和for循环
        var list = [1,2,3];
        for(i in list){
           console.log(i,list[i]);
        }
        var obj = {name:'zhansan',age:18,sex:'nan'}
        for(i in obj){
            console.log(i,obj[i]);
        }
        for(var i = 0;i<10;i++){
            console.log(i);
        }
      </script>
    </body>
</html>

 

posted @ 2019-07-29 17:05  我只是一个码农  阅读(201)  评论(0编辑  收藏  举报