JavaScript Array.prototype.forEach() Guide

JavaScript Logo

Array.prototype.forEach() – Executes a callback for every element **without returning** a new array. Suitable for side‑effects.

๐Ÿ‘‰ Syntax

array.forEach((element, index, array) => {
  // side‑effect only
}, thisArg);

๐Ÿงช Example

['๐ŸŽ','๐ŸŒ','๐ŸŠ'].forEach((f,i) => console.log(i, f));

Comments