Returns values where predicate returns true.
predicate
If you just want the first match, use find
find
Map
Filtering predicate
Values that match predicate
// for-of loopfor (const v of filter(people, person => person.age > 30)) {}// If you want an arrayconst overThirty = Array.from(filter(people, person => person.age > 30)); Copy
// for-of loopfor (const v of filter(people, person => person.age > 30)) {}// If you want an arrayconst overThirty = Array.from(filter(people, person => person.age > 30));
Returns values where
predicate
returns true.If you just want the first match, use
find