Table of Contents
- forEach Loop
- Filter Method
- Map Method
- Reduce Method
- Set Data Structure
- Map Data Structure
1. forEach Loop
What is forEach?
forEach is an array method that iterates over each element and executes a callback function for each element.
Syntax
javascript
array.forEach((element, index, array) => { *// code to execute* });
Parameters
- element (mandatory): Current element being processed
- index (optional): Index of current element
- array (optional): The entire array
Example
javascript