1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JavaScript 配列と繰り返し

Last updated at Posted at 2020-05-28

配列と繰り返し処理

配列と繰り返し処理の1例を紹介していきます。
(例) for文を使って、配列の要素を順番に取り出す

sample.js
const color = ["red", "blue", "yellow"];

for(let i = 0; i < color.length; i++) {
    //iが配列内の要素の数だけループする
  console.log(color[i];//変数iを用いて要素を取得
}
red
blue
yellow

for文を使用することで配列の中に格納されているすべての値を簡単に出力することができます。
また、配列.lengthとすることで配列の要素数を取得できます。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?