Tin mới
JavaScript: Scripting language
Web APIs: Programming interfaces
Structuring content with HTML module
Dynamic scripting with JavaScript module
The forEach() method is an iterative method. It calls a provided callbackFn function once for each element in an array in ascending-index order. Unlike map(), forEach() always returns undefined and is not chainable. The
Note: If passing the callback function used an arrow function expression, the thisArg parameter could be omitted, since all arrow functions lexically bind the this value.
The following example is only here for learning purpose. If you want to flatten an array using built-in methods, you can use Array.prototype.flat().
TypedArray.prototype.forEach()
This page was last modified on May 22, 2026 by MDN contributors.