I can't break _.forEach loop, help me to do that.
_.forEach(oIncludedFileMap, function (aIncludedFiles, sKey) { if(aIncludedFiles == null){ break; } });
Javascript. Conclusion: Hence to break Lodash forEach loop we have to return false from the callback function.
Officially, there is no proper way to break out of a forEach loop in javascript. Using the familiar break syntax will throw an error. If breaking the loop is something you really need, it would be best to consider using a traditional loop.
Syntax. _.forEach(collection, [iteratee=_.identity]) Iterates over elements of collection and invokes iteratee for each element. The iteratee is invoked with three arguments: (value, index|key, collection). Iteratee functions may exit iteration early by explicitly returning false.
To finish lodash#forEach
method use return false;
statement:
_.forEach(oIncludedFileMap, function(aIncludedFiles, sKey) { if (aIncludedFiles == null) { return false; } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With