[ES6] for of文で配列要素の値を取得
書式
for(const 変数名 of 配列名)
使用例
<script>
const intArr = [11, 22, 10];
const strArr = ["study", "skill", "arkgame"];
//int配列 for of処理
for(const val of intArr) {
alert(val);
}
//string配列 for of処理
for(const val of strArr) {
alert(val);
}
</script>
<script>
const intArr = [11, 22, 10];
const strArr = ["study", "skill", "arkgame"];
//int配列 for of処理
for(const val of intArr) {
alert(val);
}
//string配列 for of処理
for(const val of strArr) {
alert(val);
}
</script>
<script> const intArr = [11, 22, 10]; const strArr = ["study", "skill", "arkgame"]; //int配列 for of処理 for(const val of intArr) { alert(val); } //string配列 for of処理 for(const val of strArr) { alert(val); } </script>
結果
11
22
10
study
skill
arkgame