var a=new Array();
a[0]=new Array();
a[1]=new Array();
a[2]=new Array();
a[3]=new Array();
下面是一个事例
实现代码如下:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<script type="text/javascript">
function func() {
var mXn = new Array(8);
for (var i = 0; i < 8; i++) {
mXn[i] = new Array();
for(var j=0;j<8;j++)
{
mXn[i][j]="第"+i+"行"+j+"列";
}
}
document.write("<table border=\"1\" width=\"700\">");
for (var i = 0; i < 8; i++) {
document.write("<tr>");
for (var j = 0; j < 8; j++) {
document.write("<td>");
document.write(mXn[i][j]);
document.write("</td>");
}
document.write("</tr>");
}
}
func();
</script>
</body>
</html>
以上就是【定义JavaScript二维数组采用定义数组的数组来实现】的全部内容了,欢迎留言评论进行交流!