0
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 1 year has passed since last update.

for ... in の使い方

Posted at

自分の備忘録です。

JavaScript for...inの使い方

繰り返し処理の一つ
配列に対して使用する。
配列の要素を一つずつ取り出し、要素を構成するkeyを変数に持って処理をする

コード

let array = {key1: value1,key2:value2};
for(let str in array){
 console.log(str);
 console.log(array[str]);
}

出力

key1
value1
key2
value2

私の場合の利用場面

kintoneのカスタマイズに利用
kintoneではフィールドコードをハッシュの形で利用する為、
for inの利用でフィールドコードを取得できることを利用する場面がある。

0
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
0
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?