Showing posts with label inclusiveor. Show all posts
Showing posts with label inclusiveor. Show all posts

Wednesday, February 26, 2014

Lodash Where Inclusive Or

I really like using the Lodash where() function for filtering arrays. Something about it makes for elegant, condensed code — two very big wins in my opinion. For example, you can pass complex conditions in an object that test for property value equality. Each property is "and"ded together. The where() function loses some of it's power when you want to combine expressions using "and" and "or". Often, the result is me writing a function to do the complex filtering, and passing that to where(). But there's another way to do it.