2次元配列

配列の配列を作ることで2次元配列を作ることができます.

JavaScript の例

<SCRIPT LANGUAGE="JavaScript">
	var a = new Array(2);
	a[0] = new Array(2);
	a[1] = new Array(2);

	a[0][0] = 11;
	a[0][1] = 12;
	a[1][0] = 21;
	a[1][1] = 22;
	for (i = 0; i < a.length; i++) {
		for (j = 0; j < a[i].length; j++) {
			document.write("a[",i,"][",j,"] = ", a[i][j], "<BR>");
		}
	}
</SCRIPT>

上記JavaScriptの実行結果


目次に戻る