how to break the _.each function in underscore.js

I’m looking for a way to stop iterations of underscore.js _.each() method, but can’t find the solution. jQuery .each() can break if you do return false.

Is there a way to stop underscore each()?

_([1,2,3]).each(function(v){
    if (v==2) return /*what?*/;
})

11 Answers
11

Leave a Comment