「Google Apps Script」forとof文で配列の全て要素を取得する
構文
const 配列名 = [要素1,要素2,xxx];
for (変数名 of 配列オブジェクト名){
処理コード
}
for文にofを使って配列の全ての要素を取得します。
使用例
function myFunction() {
const cityArr = ["東京", "大阪", "福岡","横浜"];
for (const ss of cityArr) {
console.log(ss);
}
}
function myFunction() {
const cityArr = ["東京", "大阪", "福岡","横浜"];
for (const ss of cityArr) {
console.log(ss);
}
}
function myFunction() { const cityArr = ["東京", "大阪", "福岡","横浜"]; for (const ss of cityArr) { console.log(ss); } }
実行結果
東京
大阪
福岡
横浜
東京
大阪
福岡
横浜
東京 大阪 福岡 横浜