Selecting elements with lodash where inner properties match values in an array
问题 I currently have the following and want to know if there is a cleaner way to do it since I do not like the inclusion of the flag. const countries = [...]; const religionFilter = [ "religA", "religB" ]; const religionFilteredCountries = []; _.forEach(countries, c => { let flag = false; _.forEach(c.info, i => { if (_.includes(religionFilter, i.religions)) { flag = true; } }); if (flag) { religionFilteredCountries.push(c); } } ); Here is a jsfiddle. Here is the updated jsfiddle. 回答1: Since you