Creates a generator that filters out null and undefined values from an iterable.
Type of elements in the iterable
The source iterable to filter
A generator yielding only non-null, non-undefined values
All non-nullish values from the source iterable
// Filter out nullish valuesconst results = [...compact([1, null, 2, undefined, 3])]// Result: [1, 2, 3] Copy
// Filter out nullish valuesconst results = [...compact([1, null, 2, undefined, 3])]// Result: [1, 2, 3]
defined - For filtering out only undefined values (preserving null)
Creates a generator that filters out null and undefined values from an iterable.