Array.prototype.forEach()
Array.prototype.forEach() is a JavaScript method in the Array category. Executes a provided function once for each array element. The syntax is array.forEach(callbackFn, thisArg). It returns undefined. A typical example: [1, 2, 3].forEach(x => console.log(x)). Its time complexity is O(n), which matters when it runs over large inputs. The TypeScript signature is (callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void. Common pitfall — Cannot break out of forEach(). forEach() cannot be stopped. Use for...of if you need to break early, or use some()/every() which can short-circuit. Watch out for forEach() ignores the return value: Returning a value from forEach() does nothing. If you need a new array, use map(). A close sibling is Array.prototype.map(), which creates a new array populated with the results of calling a provided function on every element. A close sibling is Array.prototype.filter(), which creates a new array with all elements that pass the test implemented by the provided function.