where
parses constraints to create a predicate for filtering
Intro
where
takes a spec object and returns a testSpec function. The testSpec function will return
true
if it is passed a matching test object, otherwise it returns false.
This pattern can be used to filter objects in arrays or object streams. Primitives as spec objects
will perform a strict (===
) equals check against the test object.
var arr = x: 2 y: 1 x: 10 y: 2 x: 8 y: 3 x: 9 y: 4;arr; //=> [{x: 10, y: 2}]arrlength; //-> 31 2 null 3; //=> true1 2 null 3; //=> false