首页 > 代码库 > JS初学之-for套for遍历二维数组

JS初学之-for套for遍历二维数组

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
<script>
var arr=[[1,2],[3,4],[5,6],[7,8]];

for(var i=0;i<arr.length;i++){
for(var j=0;j<arr[i].length;j++){
alert(arr[i][j]);
};
};
</script>
</body>
</html>

JS初学之-for套for遍历二维数组