其他分享
首页 > 其他分享> > js循环二维数组,输出左下半区

js循环二维数组,输出左下半区

作者:互联网

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var bigArr=[]
        var smallArr=[]
        for(var i=1;i<=25;i++){
            smallArr.push(i)
            if(smallArr.length===5){
                bigArr.push(smallArr);
                smallArr=[]
            }
        }
        for(var j=0;j<bigArr.length;j++){
            // console.log(bigArr[j])
            bigArr[j].length=j+1;
        }    
        console.log(bigArr);   
    </script>
</body>
</html>

标签:smallArr,js,var,二维,下半区,bigArr,Document
来源: https://www.cnblogs.com/cengzhuquan/p/13940388.html