From the Mozilla Developer Network:
There is no way to stop or break a
forEach()loop other than by throwing an exception. If you need such behavior, the
forEach()method is the wrong tool.
Early termination may be accomplished with:
- A simple loop
~ Answered on 2016-01-07 11:10:47