JavaScriptで次のような二次元配列を設定する方法。
img_ary[0][0] = ‘花’
img_ary[0][1] = ‘http://sample.com/java/flower.jpg’
img_ary[1][0] = ‘鳥’
img_ary[1][1] = ‘http://sample.com/java/bard.jpg’
img_ary[2][0] = ‘アザラシ’
img_ary[2][1] = ‘http://sample.com/java/seal.jpg’
リテラルで設定する場合
var img_ary = [['花','http://sample.com/java/flower.jpg'], ['鳥','http://sample.com/java/bard.jpg'], ['アザラシ','http://sample.com/java/seal.jpg']];
代入で設定する場合
var img_ary = []; 中略 img_ary[0] = new Array('花','http://sample.com/java/flower.jpg'); img_ary[1] = new Array('鳥','http://sample.com/java/bard.jpg'); img_ary[2] = new Array('アザラシ','http://sample.com/java/seal.jpg'); もしくは var img_ary = []; 中略 img_ary[0] = new Array(); img_ary[0][0] = '花'; img_ary[0][1] = 'http://sample.com/java/flower.jpg'; img_ary[1] = new Array(); img_ary[1][0] = '鳥'; img_ary[1][1] = 'http://sample.com/java/bard.jpg'; img_ary[2] = new Array(); img_ary[2][0] = 'アザラシ'; img_ary[2][1] = 'http://sample.com/java/seal.jpg';