During each execution in the forEach loop, the current element is passed as an argument to the callback function what does that mean?

I was reading the topic of forEach loop in the JavaScript course

  • then I came across this line where it says ".forEach() loops through the array and executes the callback function for each element. During each execution, the current element is passed as an argument to the callback function.

Here is the link to that

My question is that if the current element is an array then during each execution does it pass the whole array or does the function keeps slicing the array to obtain the index or however it works.

Please let me know if I am getting something wrong.

It means the callback is invoked for each value in the array. The current value becomes the argument when forEach invokes it.

Think in terms of a for of loop.

const array = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for (let x of arr) {

Now relate it to the forEach() iterator.

const print = function (x) {


In the above, print is the callback reference. The iterator does all the looping internally and supplies its own iteration variable.