- Instant help with your JavaScript coding problems
forEach
Executes a provided function once for each array element.
JavaScript:
forEach((element) => { /* … */ })
TypeScript:
forEach(callbackfn: (value: Node, key: number, parent: NodeList) => void, thisArg?: any): void;
Examples:
const items = [1, 2, 3];

items.forEach((item) => {
  console.log(item * 2);
});

Related snippets