Returns the first element in the source that satisfies the predicate or a default value.
Type of items in the source.
Default value or factory to use if no element satisfies the predicate.
Predicate function to determine if an element should be returned.
Collector that returns the first element in the source that satisfies the predicate or a default value.
const result = firstOrDefault<number>(0, (x) => x > 1)([1, 2, 3]);console.log(result); // 2 Copy
const result = firstOrDefault<number>(0, (x) => x > 1)([1, 2, 3]);console.log(result); // 2
Returns the first element in the source that satisfies the predicate or a default value.