• Category

    Determines whether any of the elements of an iterable pass a given predicate.

    Time complexity: O(n)

    Space complexity: O(1)

    Type Parameters

    • T

    Parameters

    • iterable: Iterable<T>

      The iterable to take elements from

    • predicate: ((element: T) => unknown)

      The function to call on each element in the iterable to determine if it passes the test

        • (element): unknown
        • Parameters

          • element: T

          Returns unknown

    Returns boolean

    true if any element passes the predicate, false otherwise

    Iterable

    some([false], x => x); // false
    
    some([false, true], x => x); // true
    
    some([true], x => x); // true