JavaScript forEach文で2次元配列の要素を取得する
環境
Google Chrome 106.0.5249.62
Windows 10 Home 64bit
書式
const 2次元配列名 = [ [要素1,要素2,..],..]:
配列名.forEach(function(value,index) {処理コード});
使用例
const cft = [ ["A01", "B02", "C03"], ["T01", "S02", "R03"], ]; cft.forEach(function (value, index) { console.log(value); console.log(value[0] + "," + value[1] + "," + value[2]); });
実行結果
> Array ["A01", "B02", "C03"] > "A01,B02,C03" > Array ["T01", "S02", "R03"] > "T01,S02,R03"