Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
Since March 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
forEach() は Iterator インスタンスのメソッドで、 Array.prototype.forEach() と似ています。指定された関数を、イテレーターによって生成されたそれぞれの要素に対して 1 回ずつ指定された関数を実行します。
イテレーターによって生成された各要素に対して実行する関数。その返値は破棄されます。関数は次の引数で呼び出されます。
element処理中の現在の要素です。
index処理中の現在の要素のインデックスです。
undefined です。
forEach() はイテレーターを反復処理し、それぞれの要素に対して一度ずつ callbackFn 関数を呼び出します。 他のほとんどのイテレーターヘルパーメソッドとは異なり、これは遅延的ではないため、無限イテレーターでは動作しません。
これは次のものと同等です。
| ECMAScript® 2027 Language Specification # sec-iterator.prototype.foreach |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2026年2月13日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.