What does `return` keyword mean inside `forEach` function?

The Solution to What does `return` keyword mean inside `forEach` function? is


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:

The other Array methods: every(), some(), find(), and findIndex() test the array elements with a predicate returning a truthy value to determine if further iteration is required.

~ Answered on 2016-01-07 11:10:47


Most Viewed Questions: