# for-in文

**for-in文**はオブジェクトの全てのプロパティにて処理を行いたい場合に使用します。

下記にて、productのkeyを`key`という変数に格納され、全てのプロパティ名を取得することができます。また各プロパティの値を取得したい場合は、product\[key]とすることで全てのプロパティの値を取得することができます。

<pre class="language-javascript" data-title="index.js◎"><code class="lang-javascript">...
  i++;
};

<strong>let product = {
</strong><strong>  name: 'りんご',
</strong><strong>  price: 100,
</strong><strong>};
</strong><strong>for (let key in product) {
</strong><strong>  console.log(key);
</strong><strong>  console.log(product[key]);
</strong><strong>};
</strong></code></pre>
