filter
Creates a new Map containing only the entries for which the predicate returns true.
Available since v3.0.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
map | ReadonlyMap<K, V> | The Map to filter |
predicate | function | Function invoked with (value, key) — return true to keep the entry |
Returns
Section titled “Returns”Map<K, V> — A new Map with only the matching entries
Examples
Section titled “Examples”Keep only even values
Section titled “Keep only even values”Creates a new Map with only the entries whose value satisfies the predicate.
No matches
Section titled “No matches”Returns an empty Map when nothing matches.
