In JavaScript, forEach() is a FUNCTION that loops over an array of elements.It takes a callback as a parameter and applies it to every element in the array.I know that you landed on this page to know the direct way to break from forEach(), but I'm sorry to tell you that you can't.As MDN:
There is no way to stop or break a forEach() loop other than by throwing an exception.
There is no way to stop or break a forEach() loop other than by throwing an exception.
[
add
]
[
|
|
...
]