Javascript - .forEach()
📖 Read the lesson
Code Life
By Pierre Marsaa
A Built-in Loop
Arrays have a special method for looping over their elements:
forEach
. It takes a callback and calls it once per element.
↗️
Loading editor...
↶
▶️ Run
↷
It's a method of the array, so it's called with a dot. The callback receives each element in turn, exactly like the loop variable of
for
...of
.
Loading editor...
Verify