You can use _.some when the function passed returns the true value, the iteration stops, and true is returned. If it cannot find the true value, it will return false after iterating over the entire array.
Example:
_.forEach(self._connectedClients, function(client) { if (client.authenticated) { if (_.some(client.interests, _.method('test', evt.event_type))) { self._sendJSON(client.socket, data); } } });
source share