DEV Community

Discussion on: My Top 3 JavaScript Array Methods

 
jamesthomson profile image
James Thomson

You sure about that? AFAIK forEach will continue to run until the end of the array.

jsfiddle.net/jamesbrndwgn/mz0ynkvb/

Unless there's some trick I'm not aware of?

Thread Thread
 
berniwittmann profile image
Bernhard Wittmann • Edited

Ah I'm sorry I understood you wrong. I thought you meant skipping an element like continue. You meant completely stop after a certain element. This is currently not possible with forEach, but you could use for (obj of array) or some instead to achieve that behavior
Sorry again for the misunderstanding