Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@mofuko0213

JavaScript 配列と繰り返し

配列と繰り返し処理

配列と繰り返し処理の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とすることで配列の要素数を取得できます。

0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
mofuko0213
プログラミング初心者です。 日頃学習したことをアウトプットしていきます。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?